import java.io.*; import java.util.Date; public class SplitFiles { FileInputStream fin; FileOutputStream fout; int len; int splitlen; String str; SplitFiles() { try { fin=new FileInputStream("d:\\try.txt"); //str=fileName; len=0; splitlen=1024; Split(); } catch(FileNotFoundException e) { System.out.println("File not found."); } catch(IOException e) { System.out.println("IOException generated"); } } void Split() { try { int i=0; FileInputStream fin=new FileInputStream("d:\\try.txt"); int c=fin.read(); while(c!=-1) { FileOutputStream fw=new FileOutputStream("D:\\Manoj_Zete\\auto generated records\\"+new Date().getTime()+".txt"); while(c!=-1 && len<splitlen)> { fw.write(c); c=fin.read(); len++; } len=0; fw.close(); i++; } } catch(Exception e) { e.printStackTrace(); } } public static void main(String ar[]) { new SplitFiles(); } }
SIZE
N
N = (splitlen / SIZE)* SIZE;
read size > splitsize
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)