Results 1 to 3 of 3
  1. #1
    newwork01 is offline Member
    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    Default java load big text file

    I want to load a big text file (about 500mb) and put the content to a list<object> . The Requirement is : When I run the program next times , it don't spend much time for processing data . i think of caching the text file or the content of it but don't know where to start ? Can anyone help me ?

  2. #2
    Join Date
    Dec 2013
    Location
    Israel, Karmiel
    Posts
    4
    Rep Power
    0

    Default Re: java load big text file

    500mb is not a big file, it is much less than the typical volume of RAM (wher it will be probably unpacked to 1 GB, 2 bytes per character). On modern disks, it should be loaded in 5-10 seconds. Moreover, Java standard BufferedReader should read such a file with good speed - I think the CPU time for processing characters and extracting lines will be much less than the time for reading from disk. What do you want to optimize? Do you have results of time measurements of the simplest solution (via BufferedReader)?

  3. #3
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,277
    Rep Power
    6

    Default Re: java load big text file

    But what if the file is loaded over the network or in an environment where the disc really isn't so fast such as on an Android device? Then all of a sudden 500mb IS a whole lot to process in one go and this becomes a very reasonable question.

    OP: It would be better to explain what your functional requirements are; what kind of data is in the file and what do you intend to do with it. Based on that someone might be able to give some tips on how to approach loading the file in a more intelligent matter than brute-force dumping it into memory.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. How to load a text file into a list on start-up?
    By delimanyak in forum New To Java
    Replies: 2
    Last Post: 05-02-2012, 10:45 PM
  2. java load file to textarea, thanks in advance
    By farahm in forum New To Java
    Replies: 1
    Last Post: 03-26-2011, 05:31 PM
  3. Add a jar file to Java load path at run time
    By marioneil in forum Advanced Java
    Replies: 5
    Last Post: 09-22-2010, 08:58 AM
  4. load a text in a view
    By bulldo in forum Eclipse
    Replies: 4
    Last Post: 08-17-2010, 02:57 PM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 10:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •