Results 1 to 3 of 3

Thread: Buffered Reader

  1. #1
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default Buffered Reader

    I need to create a java program that reads a text file line by line, and inserts each line of text into a long[]. I'm using Buffered Reader, but I can only get it to read the line of text as a String. Is there any way to avoid parsing each line from String to Long?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    A Reader only reads in Strings. If the file is a non-text file with binary data, you can read this in with say a (buffered) DataInputStream or if it's a serialized object then a buffered ObjectInputStream. Otherwise if it is text, then you'll likely want to use a Scanner object to read in the text and convert to longs, or use your reader and convert it yourself.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

Similar Threads

  1. Buffered Reader problem
    By pradeep.theonlyone in forum New To Java
    Replies: 3
    Last Post: 07-31-2009, 12:37 PM
  2. Buffered Reader Exception
    By hitmen in forum New To Java
    Replies: 6
    Last Post: 01-07-2009, 12:14 PM
  3. Unable to draw buffered image
    By pedjasmek in forum Java 2D
    Replies: 7
    Last Post: 08-08-2008, 04:49 PM
  4. FileReader / Buffered Reader
    By sepaht in forum New To Java
    Replies: 9
    Last Post: 07-10-2008, 09:05 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
  •