大家好,
我是不是有一堆 *.zip 文件在这个文件中有很多 *.log 文件和其他东西和一个 *.xml 文件。
我需要找到该文件并将其复制到另一个目录。
到目前为止,我在 *.zip 文件夹中找到了该文件,但现在我卡住了。希望你们能帮助...谢谢
以下代码我到目前为止:
public static void main(String[] args)
{
String sPath = "c:/results/";
//String sFiles;
File folder = new File(sPath);
File[] aListOfFiles = folder.listFiles();
try
{
//get all files in the folder
for (int i = 0; i < aListOfFiles.length; i++)
{
if (aListOfFiles[i].isFile())
{
//get path an file name
String sZipPath = aListOfFiles[i].getAbsolutePath();
//System.out.println("Absolute Path: " + sZipPath);
//open zip find the xml
ZipFile sourceZipFile = new ZipFile(sZipPath);
Enumeration e = sourceZipFile.entries();
while(e.hasMoreElements())
{
ZipEntry entry = (ZipEntry)e.nextElement();
String isXML = entry.getName();
if (isXML.endsWith(".xml"))
{
System.out.println(isXML);
//copieFile(File isXML,)
}
}
}
}
}
catch (IOException ioe)
{
System.out.println("Error while opening zip file " + ioe);
}