I am trying to send chunks of files from server to more than one clients. When I am trying to send file of size 700mb, it showed "OutOfMemory java heap space" error. I am using Netbeans 7.1.2 version. I also tried VMoption in the properties. But still the same error happens. I think there is some problem with reading the entire file. Below code is working for up to 300mb. Please give me some suggestions.
Thanks in advance
public class SplitFile {   
    static int fileid = 0  ;
    public static DataUnit[] getUpdatableDataCode(File fileName) throws FileNotFoundException, IOException{
    int i = 0;
    DataUnit[] chunks = new DataUnit[UAProtocolServer.singletonServer.cloudhosts.length];
    FileInputStream fis;
    long Chunk_Size = (fileName.length())/chunks.length;
    int cursor = 0;
    long fileSize = (long) fileName.length();
    int nChunks = 0, read = 0;long readLength = Chunk_Size;
    byte[] byteChunk;
    try {
        fis = new FileInputStream(fileName);
        //StupidTest.size = (int)fileName.length();
        while (fileSize > 0) {
            System.out.println("loop"+ i);
            if (fileSize <= Chunk_Size) {
                readLength = (int) fileSize;
            }
            byteChunk = new byte[(int)readLength];
            read = fis.read(byteChunk, 0, (int)readLength);
            fileSize -= read;
           // cursor += read;
            assert(read==byteChunk.length);                                          
            long aid = fileid;
            aid = aid<<32 | nChunks;                
            chunks[i] = new DataUnit(byteChunk,aid);                
         //   Lister.add(chunks[i]);
            nChunks++;
            ++i;                       
        }
        fis.close();
        fis = null;
      }catch(Exception e){
            System.out.println("File splitting exception");
        e.printStackTrace();
    }
       return chunks;               
    }
 
     
    