1

I have a 4Gb file.

path = "D:\Try\FourGBFile.txt"

Say,

File file = new File(path);

I wanna split the contents of this file into 4 files. How would i do it?

leppie
  • 115,091
  • 17
  • 196
  • 297
Prasanna
  • 2,593
  • 7
  • 39
  • 53

1 Answers1

0
  1. Get the length of the file:

    long len = file.length();
    
  2. Open a FileInputStream to your source file

  3. Open as many FileOutputStream as you want/need

  4. Write each part of the file by reading from the input stream and writing to the respective output stream, using the length of the file

maxdev
  • 2,491
  • 1
  • 25
  • 50