Results 1 to 3 of 3
  1. #1
    bbq
    bbq is offline Senior Member
    Join Date
    Jun 2007
    Posts
    132
    Rep Power
    0

    Default BufferedReader: readLine method problems

    I'm reading a txt file that contents a text line under the other text line, when I read each line and then print them, it prints without the first character

    for example :
    Apples
    bread
    but the program shows this
    pples
    read
    this is the code

    Java Code:
    
    
    FileInputStream _file = new FileInputStream(pFile);
    
                BufferedReader _text= new BufferedReader(new InputStreamReader(_file));
    
     
    
                while ( _text.read() != -1 ) {
    
                            System.out.println(_text.readLine());
    
                }
    
               
    
    _text.close();
    any ideas?

  2. #2
    topsyturvy is offline Member
    Join Date
    Jun 2007
    Posts
    2
    Rep Power
    0

    Default

    try this:

    BufferedReader _text= new BufferedReader(new FileReader(yourFile));


    String line ="";
    while ((line=_text.readline())!=null) {

    System.out.println(line);

    }

  3. #3
    bbq
    bbq is offline Senior Member
    Join Date
    Jun 2007
    Posts
    132
    Rep Power
    0

Similar Threads

  1. Problems with readLine() and calling methods
    By peachyco in forum New To Java
    Replies: 2
    Last Post: 11-24-2007, 07:44 AM
  2. problems to find the main method
    By christina in forum Eclipse
    Replies: 2
    Last Post: 08-06-2007, 07:51 PM
  3. problems with replace method
    By cecily in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 09:11 PM
  4. Problems with method
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 06-28-2007, 06:49 PM
  5. Problems with Find method in EJB
    By Nick15 in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 05-14-2007, 01:29 PM

Posting Permissions

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