Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. #
  2. public static void run() throws Exception{
  3. #
  4.  
  5. #
  6.                  StringBuffer fileContents = new StringBuffer();
  7. #
  8.  
  9. #
  10.                  FileInputStream fi = new FileInputStream(new File("text.in"));
  11. #
  12.  
  13. #
  14.              int line = 0;
  15. #
  16.            
  17. #
  18.              while ((line = fi.read()) != -1)
  19. #
  20.                  fileContents.append(line).append("\n");
  21. #
  22.            
  23. #
  24.              processFile(fileContents.toString());
  25. #
  26.              String s = compress(fileContents.toString());
  27. #
  28.              
  29. #
  30.              BufferedOutputStream bw = new BufferedOutputStream(new FileOutputStream(new File("compressed.out")));
  31. #
  32.              //System.out.println(s);
  33. #
  34.              String tmp;
  35. #
  36.              for (int j = 0; j < s.length(); j+=8)
  37. #
  38.              {
  39. #
  40.                  
  41. #
  42.                  if (j + 8 < s.length()-8)
  43. #
  44.                          tmp = s.substring(j, j + 8);
  45. #
  46.                 else
  47. #
  48.                         tmp = s.substring(j, s.length() - 1);
  49. #
  50.                  
  51. #
  52.                  int x= Integer.parseInt(tmp,2);
  53. #
  54.                  System.out.println(x);
  55. #
  56.                  bw.write(x);
  57. #
  58.              }
  59. #
  60.                
  61. #
  62.              bw.close();
  63. #
  64.              
  65. #
  66.                 System.out.println("finish");
  67. #
  68.  
  69. #
  70.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement