aznishboy

Squeeze

Nov 29th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.77 KB | None | 0 0
  1.  
  2. import chn.util.*;
  3. public class Squeeze
  4. {
  5.     public Squeeze(FileInput inFile, FileOutput outFile)
  6.     {
  7.         String line;
  8.         String inLine = "";
  9.         int indents = 0;
  10.         while(inFile.hasMoreLines())
  11.         {
  12.             line = inFile.readLine();
  13.             for (int i = 0; i < line.length(); i++)
  14.             {
  15.                 if (line.charAt(i) == '\t')
  16.                     indents ++;
  17.                 else inLine += line.charAt(i);
  18.             }
  19.             System.out.println(indents + " " + inLine);
  20.             outFile.println(indents + " " + inLine);
  21.             inLine = "";
  22.             indents = 0;
  23.         }
  24.         outFile.close();
  25.     }
  26.  
  27.     public static void main(String[] args)
  28.     {
  29.         FileInput inFile = new FileInput("F:\\APCS\\Unit 5\\before.txt");
  30.         FileOutput outFile = new FileOutput("F:\\APCS\\Unit 5\\after.txt");
  31.        
  32.         Squeeze compressed = new Squeeze(inFile, outFile);
  33.     }
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment