title: splitting a huge sql file to multiple sql files
body: <p>I have a huge SQL file that I want to restore to mysql server 5.5 .... while I'm restoring the the file at the middle of restoring process stopped, then i got an idea to split that file to several files using java ... is anybody got the  the idea how to split the SQL file into several files .....
  the following code  is for the java class that i create to split the SQL file... this class can create for each line in the sql huge file a file"which is not usable", i would like to split the SQL file so i can have files which is able to be restored in the mysql-server </p>
  
  <pre><code>import java.io.*;
  
  import java.io.FileWriter;
  
  class DataBase 
  
  {
   public static void main(String args[]){
  
    try{
  
    FileInputStream fstream = new FileInputStream("D:/dewiki-20110831-site_stats.sql");
  
    DataInputStream in = new DataInputStream(fstream);
  
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
  
    String strLine;
  
    File f;
  
    int i=1;
  
    while ((strLine = br.readLine()) != null){
  
          f=new File("D:/myfile"+i+".sql");
  
    if(!f.exists()){
  
    f.createNewFile();
  
    PrintWriter out = new PrintWriter(new FileWriter(f));
  
    out.write(strLine);
  
    out.close();
  
    }
  
    System.out.println (strLine);
  
    i++;
  
    }
  
    in.close();
  
      }catch (Exception e){
  
    System.err.println("Error: " + e.getMessage());
  
    }
  
    }
  
  }
  </code></pre>