1

I maded a simple java server program that send files to client.

The program works fine but when i load a very big file (1 GB) it takes 2 or 3 minutes for this line of code:

byte[] data = Files.readAllBytes(path);

Is there a wat to bypass this or make it faster (maybe by using a library)?

Thank's!

10
  • 4
    Why do you load it all into memory? Why don't you stream it? Commented Aug 11, 2014 at 6:24
  • more to the point, why not just wiki.nginx.org/XSendfile ? Commented Aug 11, 2014 at 6:25
  • 1
    @markspace this method already uses nio. Commented Aug 11, 2014 at 6:30
  • 1
    What makes you think it can be done faster? And why do it at all? Any file can be processed a piece at a time, even XML. Commented Aug 11, 2014 at 6:39
  • 1
    ...and, in many cases, loading the big file in chunks means that you can start processing the data while waiting for more to be delivered. Commented Aug 11, 2014 at 7:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.