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 org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12 import java.util.zip.InflaterInputStream;
14 public class Cws2Fws {
16 private static final Logger logger = LoggerFactory.getLogger(Cws2Fws.class);
17 private static final String CWS = "CWS";
18 private static final String FWS = "FWS";
23 * @return 圧縮SWFであればtrue.
25 public static boolean isCws(File file) {
26 BufferedInputStream bis = null;
28 bis = new BufferedInputStream(new FileInputStream(file));
29 byte header[] = new byte[CWS.length()];
30 bis.read(header, 0, header.length);
31 if (CWS.equals(new String(header))) {
34 } catch (IOException ex) {
35 logger.error(null, ex);
40 } catch (IOException ex) {
41 logger.error(null, ex);
51 * @return 展開後のファイル. 対象が圧縮SWFでなければnull.
53 public static File createFws(File in, File out) {
57 BufferedInputStream bis = null;
58 BufferedOutputStream bos = null;
60 byte buffer[] = new byte[1024];
61 bis = new BufferedInputStream(new FileInputStream(in));
62 bis.read(buffer, 0, CWS.length()); // CWS
63 bis.read(buffer, 0, 5); // その他ヘッダ
65 bos = new BufferedOutputStream(new FileOutputStream(out));
66 bos.write(FWS.getBytes());
67 bos.write(buffer, 0, 5);
69 InflaterInputStream iis = new InflaterInputStream(bis);
71 int res = iis.read(buffer);
75 bos.write(buffer, 0, res);
78 } catch (IOException ex) {
79 logger.error(null, ex);
84 } catch (IOException ex) {
85 logger.error(null, ex);
91 } catch (IOException ex) {
92 logger.error(null, ex);