Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* */ package com.gmail.goroh.kun.tools;
- /* */
- /* */ import java.io.FileInputStream;
- /* */ import java.io.FileNotFoundException;
- /* */ import java.io.FileOutputStream;
- /* */ import java.io.PrintStream;
- /* */ import java.util.zip.Deflater;
- /* */ import java.util.zip.DeflaterOutputStream;
- /* */ import java.util.zip.InflaterInputStream;
- /* */
- /* */ public class ExtractBackup
- /* */ {
- /* */ private static void usage()
- /* */ {
- /* 8 */ System.out.println("usage: extractBackup [x|c] backupfile");
- /* */ }
- /* */
- /* */ private static void dumpBytes(byte[] bytes) {
- /* 12 */ for (byte b : bytes) {
- /* 13 */ System.out.print(" " + Integer.toHexString(b));
- /* */ }
- /* 15 */ System.out.println(""); }
- /* */
- /* */ public static void extract(String fname) throws Exception {
- /* 18 */ FileInputStream fis = new FileInputStream(fname);
- /* 19 */ byte[] buf = new byte[24];
- /* 20 */ fis.read(buf);
- /* 21 */ dumpBytes(buf);
- /* 22 */ FileOutputStream foshdr = new FileOutputStream(fname + ".hdr");
- /* 23 */ foshdr.write(buf);
- /* 24 */ foshdr.close();
- /* */
- /* 26 */ InflaterInputStream iis = new InflaterInputStream(fis);
- /* 27 */ FileOutputStream fos = new FileOutputStream(fname + ".tar");
- /* 28 */ byte[] buf2 = new byte[65536];
- /* */
- /* 30 */ while (iis.available() != 0) {
- /* 31 */ int len = iis.read(buf2);
- /* 32 */ if (len < 0)
- /* */ break;
- /* 34 */ fos.write(buf2, 0, len);
- /* */ }
- /* 36 */ fos.close();
- /* 37 */ iis.close(); }
- /* */
- /* */ public static void encode(String fname) throws Exception {
- /* 40 */ FileOutputStream fos = new FileOutputStream(fname + ".out");
- /* */ try {
- /* 42 */ FileInputStream fishdr = new FileInputStream(fname + ".hdr");
- /* 43 */ byte[] buf = new byte[24];
- /* 44 */ fishdr.read(buf);
- /* 45 */ dumpBytes(buf);
- /* 46 */ fos.write(buf);
- /* 47 */ fishdr.close();
- /* */ } catch (FileNotFoundException e) {
- /* 49 */ byte[] buf = {
- /* 50 */ 65, 78, 68, 82, 79, 73, 68, 32,
- /* 51 */ 66, 65, 67, 75, 85, 80, 10,
- /* 52 */ 49, 10, 49, 10, 110, 111, 110, 101, 10 };
- /* */
- /* 54 */ dumpBytes(buf);
- /* 55 */ fos.write(buf);
- /* */ }
- /* */
- /* 58 */ Deflater compresser = new Deflater();
- /* 59 */ compresser.setLevel(9);
- /* */
- /* 61 */ DeflaterOutputStream dos = new DeflaterOutputStream(fos, compresser);
- /* 62 */ FileInputStream fis = new FileInputStream(fname + ".tar");
- /* 63 */ byte[] buf2 = new byte[65536];
- /* */
- /* 65 */ while (fis.available() != 0) {
- /* 66 */ int len = fis.read(buf2);
- /* 67 */ if (len < 0)
- /* */ break;
- /* 69 */ dos.write(buf2, 0, len);
- /* */ }
- /* 71 */ dos.finish();
- /* 72 */ fos.close();
- /* 73 */ fis.close();
- /* 74 */ dos.close(); }
- /* */
- /* */ public static void main(String[] args) throws Exception {
- /* 77 */ if (args.length < 2) {
- /* 78 */ usage();
- /* */ }
- /* 80 */ if ("x".equals(args[0])) {
- /* 81 */ extract(args[1]);
- /* */ }
- /* 83 */ if ("c".equals(args[0]))
- /* 84 */ encode(args[1]);
- /* */ }
- /* */ }
- /* Location: C:\android\workspace\testProject\extractbakup.jar
- * Qualified Name: com.gmail.goroh.kun.tools.ExtractBackup
- * Java Class Version: 6 (50.0)
- * JD-Core Version: 0.5.3
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement