title: Faster way to read file
body: <p>I am working on a program that has about 400 input files and about 40 output files.
  It's simple: It reads each input file and it generates a new file with but much bigger(based on a algorithm).</p>
  
  <p>I'm using read() method from BufferedReader:</p>
  
  <pre><code>String encoding ="ISO-8859-1";
  FileInputStream fis = new FileInputStream(nextFile);
  BufferedReader reader = new BufferedReader(new InputStreamReader(fis, encoding));
  char[] buffer = new char[8192] ;
  </code></pre>
  
  <p>To read the input files I'm using this: </p>
  
  <pre><code>private String getNextBlock() throws IOException{
      boolean isNewFile = false;
  
      int n = reader.read(buffer, 0, buffer.length);
      if(n == -1) {
          return null;
      } else {
          return new String(buffer,0,n);
      }
  }
  </code></pre>
  
  <p>With each block I'm doing some checkings (like looking some string inside the block) and then I'm writing it into a file:</p>
  
  <pre><code>BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
          new FileOutputStream("fileName"), encoding));
  
  writer.write(textToWrite);
  </code></pre>
  
  <p>The problem is that it takes about 12 minutes.
  I'm trying to find something else much faster.
  Anyone have some idea about something better?</p>
  
  <p>Thanks.</p>