Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: help

Hybrid View

  1. #1

    Default help

    I am trying to read a 40M txt file into a charSequence and i get the following Error

    class FileRead
    public static void main(String args[])
    // Open the file that is the first
    // command line parameter
    FileInputStream fstream = new FileInputStream("textfile.txt");
    // Get the object of DataInputStream
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    //Read File Line By Line
    while ((strLine = br.readLine()) != null) {
    // Print the content on the console
    System.out.println (strLine);
    //Close the input stream
    }catch (Exception e){//Catch exception if any
    System.err.println("Error: " + e.getMessage());

    how can i read it into charSequence line by line?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC

    Default Re: help

    When posting code, don't forget the code or highlight tags to preserve formatting. Look at other posts for examples of how to use them.

    Read this: Lesson: Basic I/O (The Java™ Tutorials > Essential Classes)

    PS- A more meaningful subject title wouldn't have hurt. People tend to skip over generic titles like this one.

  3. #3
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Warrington, United Kingdom

    Default Re: help

    I believe that either you need to use random access to keep the memory profile low or just chuck the JVM some more memory at startup.

    -Xmx 256m
    // Json

  4. #4

    Default Re: help

    -Xmx 256m
    java acquiesce memory is 64M

    study something about java

    read this

    Java Tutorial,learn java,so easy