4 import java.io.BufferedInputStream;
5 import java.io.BufferedOutputStream;
7 import java.io.FileInputStream;
8 import java.io.FileOutputStream;
9 import java.io.IOException;
10 import java.util.logging.Level;
11 import java.util.logging.Logger;
12 import java.util.zip.InflaterInputStream;
14 public class Cws2Fws {
16 private static final String CWS = "CWS";
17 private static final String FWS = "FWS";
20 *
\88³
\8fkSWF
\82©
\82Ç
\82¤
\82©
\94»
\92è
\82·
\82é.
21 * @param file
\94»
\92è
\91Î
\8fÛ.
22 * @return
\88³
\8fkSWF
\82Å
\82 \82ê
\82Îtrue.
24 public static boolean isCws(File file) {
25 BufferedInputStream bis = null;
27 bis = new BufferedInputStream(new FileInputStream(file));
28 byte header[] = new byte[CWS.length()];
29 bis.read(header, 0, header.length);
30 if (CWS.equals(new String(header))) {
33 } catch (IOException ex) {
34 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
39 } catch (IOException ex) {
40 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
48 *
\88³
\8fkSWF
\82ð
\93W
\8aJ
\82·
\82é.
49 * @param in
\93W
\8aJ
\91Î
\8fÛ.
50 * @return
\93W
\8aJ
\8cã
\82Ì
\83t
\83@
\83C
\83\8b.
\91Î
\8fÛ
\82ª
\88³
\8fkSWF
\82Å
\82È
\82¯
\82ê
\82Înull.
52 public static File createFws(File in, File out) {
56 BufferedInputStream bis = null;
57 BufferedOutputStream bos = null;
59 byte buffer[] = new byte[1024];
60 bis = new BufferedInputStream(new FileInputStream(in));
61 bis.read(buffer, 0, CWS.length()); // CWS
62 bis.read(buffer, 0, 5); //
\82»
\82Ì
\91¼
\83w
\83b
\83_
64 bos = new BufferedOutputStream(new FileOutputStream(out));
65 bos.write(FWS.getBytes());
66 bos.write(buffer, 0, 5);
68 InflaterInputStream iis = new InflaterInputStream(bis);
70 int res = iis.read(buffer);
74 bos.write(buffer, 0, res);
77 } catch (IOException ex) {
78 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
83 } catch (IOException ex) {
84 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
90 } catch (IOException ex) {
91 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);