Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to list files in a JAR manifest file. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
List files in a JAR manifest file. 22-Aug-04
Category
Files Operation
Language
JBuilder All Versions
Views
456
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			
1 package samplecode; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 6 import java.util.jar.*; 7 import java.io.*; 8 import java.util.*; 9 10 /** 11 * <p>Title: Font Names </p> 12 * <p>Description: This program shows how to read attirbutes from a jar file</p> 13 * <p>Company: Developer's super Page.com</p> 14 */ 15 16 17 public class SampleFrame extends JFrame { 18 JPanel contentPane; 19 BorderLayout borderLayout1 = new BorderLayout(); 20 JPanel jpnlMain = new JPanel(); 21 DefaultListModel model = new DefaultListModel(); 22 JLabel jLabel1 = new JLabel(); 23 JButton jButton2 = new JButton(); 24 JTextArea jTextArea1 = new JTextArea(); 25 JTextField jTextField1 = new JTextField(); 26 JLabel jLabel2 = new JLabel(); 27 JTextField jTextField2 = new JTextField(); 28 29 //Construct the frame 30 public SampleFrame() { 31 enableEvents(AWTEvent.WINDOW_EVENT_MASK); 32 try { 33 jbInit(); 34 } 35 catch(Exception e) { 36 e.printStackTrace(); 37 } 38 } 39 40 //Component initialization 41 private void jbInit() throws Exception { 42 contentPane = (JPanel) this.getContentPane(); 43 contentPane.setLayout(borderLayout1); 44 this.setSize(new Dimension(475, 300)); 45 this.setTitle("Jar File Entry Reader"); 46 this.addHierarchyBoundsListener(new 47 SampleFrame_this_hierarchyBoundsAdapter(this)); 48 jpnlMain.setLayout(null); 49 contentPane.setMinimumSize(new Dimension(300, 300)); 50 contentPane.setPreferredSize(new Dimension(300, 256)); 51 jpnlMain.setDebugGraphicsOptions(0); 52 jpnlMain.setMinimumSize(new Dimension(400, 256)); 53 jpnlMain.setPreferredSize(new Dimension(400, 256)); 54 jpnlMain.addKeyListener(new SampleFrame_jpnlMain_keyAdapter(this)); 55 jButton2.setBounds(new Rectangle(162, 232, 148, 34)); 56 jButton2.setText("GetInfo"); 57 jButton2.addActionListener(new SampleFrame_jButton2_actionAdapter(this)); 58 jTextArea1.setText("jTextArea1"); 59 jTextArea1.setBounds(new Rectangle(11, 8, 457, 176)); 60 jLabel2.setText("File Name:"); 61 jLabel2.setBounds(new Rectangle(33, 201, 55, 19)); 62 jTextField2.setFont(new java.awt.Font("Dialog", 1, 11)); 63 jTextField2.setText("jTextField2"); 64 jTextField2.setBounds(new Rectangle(169, 195, 129, 28)); 65 contentPane.add(jpnlMain, BorderLayout.CENTER); 66 jpnlMain.add(jTextArea1, null); 67 jpnlMain.add(jLabel2, null); 68 jpnlMain.add(jTextField2, null); 69 jpnlMain.add(jButton2, null); 70 71 } 72 73 //Overridden so we can exit when window is closed 74 protected void processWindowEvent(WindowEvent e) { 75 super.processWindowEvent(e); 76 if (e.getID() == WindowEvent.WINDOW_CLOSING) { 77 System.exit(0); 78 } 79 } 80 81 82 void jButton1_actionPerformed(ActionEvent e) { 83 84 85 } 86 87 void jButton2_actionPerformed(ActionEvent e) { 88 try { 89 // used to append data in the for loop 90 String sData =""; 91 92 // Open the JAR file give by the textfield 93 JarFile jarfile = new JarFile(jTextField2.getText()); 94 95 96 // Get the manifest 97 Manifest manifest = jarfile.getManifest(); 98 99 // Get the manifest entries 100 Map map = manifest.getEntries(); 101 102 // Enumerate each entry 103 for (Iterator it=map.keySet().iterator(); it.hasNext(); ) { 104 105 // Get the name of a file in the Jar Manifest 106 String fileName = (String)it.next(); 107 108 sData+=fileName + "\n"; 109 } 110 111 jTextArea1.setText(sData); 112 } catch (IOException e1) { 113 } 114 115 } 116 117 } 118 class SampleFrame_this_hierarchyBoundsAdapter extends 119 java.awt.event.HierarchyBoundsAdapter { 120 SampleFrame adaptee; 121 122 SampleFrame_this_hierarchyBoundsAdapter(SampleFrame adaptee) { 123 this.adaptee = adaptee; 124 } 125 126 } 127 128 129 130 class SampleFrame_jpnlMain_keyAdapter extends java.awt.event.KeyAdapter { 131 SampleFrame adaptee; 132 133 SampleFrame_jpnlMain_keyAdapter(SampleFrame adaptee) { 134 this.adaptee = adaptee; 135 } 136 137 } 138 139 140 141 class SampleFrame_jButton2_actionAdapter implements java.awt.event.ActionListener { 142 SampleFrame adaptee; 143 144 SampleFrame_jButton2_actionAdapter(SampleFrame adaptee) { 145 this.adaptee = adaptee; 146 } 147 public void actionPerformed(ActionEvent e) { 148 adaptee.jButton2_actionPerformed(e); 149 } 150 }
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC