hey,
Thank you for your help,
What about a jar file, if I choose a jar file ,how can I Know all its files names that it is contained without extracting it?
There is a entries () method in a JarFile class which return enumeration for the zip file entries. So I can make a loop to extract file names, but the problem is:
That the file returned by getSelectedFile() method is a File type, but if I choose the jar file type "example : Hello.jar" ,I would like to use the entries method at this file but in the program its type is File ,
how can i make it JarFile type?
Here it is a part of a code of my program:
/*global variable*/
Static private final String newline = "\n";
[b]JFileChooser[/b]fc;
/* a part of a program code*/
//the file chosen 揷ase: if it is a jar file type?/font>
//but its type is File not JarFile
[b]File[/b] file = fc.getSelectedFile();
try {
//I tries to convert the file to jar file but it is impossible
[b]JarFile[/b] jarFile =(JarFile) file;
} catch (IOException ex) {
ex.printStackTrace();
}
//entries method to extract the files name that the jar file contains
[b]Enumeration[/b] entre = jarFile.entries();
while(entre.hasMoreElements()){
[b]File[/b] f= (File) entre.nextElement();
classList.append("openning :"+ f.toString()+"."+newLine);
}