2012-04-02 108 views
0

我已將多個jpeg文件合併爲一個.bin文件。從單個文件中分離出多個jpg文件

..... 
......... 
while(true){ 
      if (q.numOfFiles() > 0) { 
       source = q.getNextFile(); 
       in = new DataInputStream(new BufferedInputStream(new FileInputStream(source))); 
       byte[] buf = new byte[1024]; 
       int len; 
       while ((len = in.read(buf)) > 0) { 
       out.write(buf, 0, len); 
       } 
       String s = "filename=="+source.getName()+"==filename"; 
       out.write(s.getBytes()); 
       out.flush(); 
       System.out.println("merged--"+source.getName()); 
      } 
       } 
........ 
........ 

,你能看到我的附加 「文件名==」 + source.getName()+ 「= =文件名」 的每個文件的結束之後。 現在我想分開所有這些jpegs與他們的實際文件名。 我如何閱讀已插入合併文件的分隔符?

+1

我建議使用一個單獨的文件,或許拉鍊? [如何在Java中創建zip](http://www.exampledepot.com/egs/java.util.zip/CreateZip.html) – 2012-04-02 10:34:11

+0

@pedroFerreira這將會非常簡單。但我不希望任何人通過使用winzip來提取圖像。 – 2012-04-02 10:39:59

+0

你也可以在Java中提取它們。 [摘自Java中的zip](http://www.roseindia.net/tutorial/java/corejava/zip/extract.html) – 2012-04-02 10:42:13

回答