3 import java.io.BufferedInputStream;
4 import java.io.BufferedOutputStream;
6 import java.io.FileInputStream;
7 import java.io.FileOutputStream;
8 import java.io.IOException;
9 import java.util.logging.Level;
10 import java.util.logging.Logger;
11 import java.util.zip.InflaterInputStream;
17 public class Cws2Fws {
19 private static final String CWS = "CWS";
20 private static final String FWS = "FWS";
23 *
\88³
\8fkSWF
\82©
\82Ç
\82¤
\82©
\94»
\92è
\82·
\82é.
24 * @param file
\94»
\92è
\91Î
\8fÛ.
25 * @return
\88³
\8fkSWF
\82Å
\82 \82ê
\82Îtrue.
27 public static boolean isCws(File file) {
28 BufferedInputStream bis = null;
30 bis = new BufferedInputStream(new FileInputStream(file));
31 byte header[] = new byte[CWS.length()];
32 bis.read(header, 0, header.length);
33 if (CWS.equals(new String(header))) {
36 } catch (IOException ex) {
37 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
42 } catch (IOException ex) {
43 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
51 *
\88³
\8fkSWF
\82ð
\93W
\8aJ
\82·
\82é.
52 * @param in
\93W
\8aJ
\91Î
\8fÛ.
53 * @return
\93W
\8aJ
\8cã
\82Ì
\83t
\83@
\83C
\83\8b.
\91Î
\8fÛ
\82ª
\88³
\8fkSWF
\82Å
\82È
\82¯
\82ê
\82Înull.
55 public static File createFws(File in) {
59 File out = new File("fws_tmp.swf");
60 BufferedInputStream bis = null;
61 BufferedOutputStream bos = null;
63 byte buffer[] = new byte[1024];
64 bis = new BufferedInputStream(new FileInputStream(in));
65 bis.read(buffer, 0, CWS.length()); // CWS
66 bis.read(buffer, 0, 5); //
\82»
\82Ì
\91¼
\83w
\83b
\83_
68 bos = new BufferedOutputStream(new FileOutputStream(out));
69 bos.write(FWS.getBytes());
72 InflaterInputStream iis = new InflaterInputStream(bis);
74 int res = iis.read(buffer);
78 bos.write(buffer, 0, res);
81 } catch (IOException ex) {
82 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
87 } catch (IOException ex) {
88 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
94 } catch (IOException ex) {
95 Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);