title: how to split a large text file into smaller chunks using java multithread
body: <p>I'm trying to develop a multithreaded java program for split a large text file into smaller text files. The smaller files created must have a prefixed number of lines.
  For example:
  if the number of lines of input file is 100 and the input number is 10, the result of my program is to split the input file into 10 files.
  I've already developed a singlethreaded version of my program:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.PrintWriter;
  
  public class TextFileSingleThreaded {
  
      public static void main(String[] args) {
          if (args.length != 2) {
              System.out.println("Invalid Input!");
          }
  
          //first argument is the file path
          File file = new File(args[0]);
  
          //second argument is the number of lines per chunk
          //In particular the smaller files will have numLinesPerChunk lines
          int numLinesPerChunk = Integer.parseInt(args[1]);
  
          BufferedReader reader = null;
          PrintWriter writer = null;
          try {
              reader = new BufferedReader(new FileReader(file));
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
  
          String line;        
  
          long start = System.currentTimeMillis();
  
          try {
              line = reader.readLine();
              for (int i = 1; line != null; i++) {
                  writer = new PrintWriter(new FileWriter(args[0] + "_part" + i + ".txt"));
                  for (int j = 0; j &lt; numLinesPerChunk &amp;&amp; line != null; j++) {
                      writer.println(line);
                      line = reader.readLine();
                  }
                  writer.flush();
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
          writer.close();
  
          long end = System.currentTimeMillis();
  
          System.out.println("Taken time[sec]:");
          System.out.println((end - start) / 1000);
  
      }
  
  }
  </code></pre>
  
  <p>I want to write a multithreaded version of this program but I don't know how to read a file beginning from a specified line. Help me please. :(</p>