Results 1 to 5 of 5
  1. #1
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    6

    Default file read as integer.

    hi.
    i have one text file that have some numbers
    like
    100 200 300
    52 45 65


    and something like that.i want to read that file and store the integer value in array.
    i tried out.
    i could read only byte and string
    any one know help me.

    regards
    mak.

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    Look at BufferedReader to read as the line. Once you have a line, split the line with space. You will have integer strings. Then convert those using Integer.parseInt.

    Look doc for these classes and functions:
    BufferedReader
    String.split()
    Integer.ParseInt
    dont worry newbie, we got you covered.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by makpandian View Post
    hi.
    i have one text file that have some numbers
    like
    100 200 300
    52 45 65


    and something like that.i want to read that file and store the integer value in array.
    i tried out.
    i could read only byte and string
    any one know help me.

    regards
    mak.
    What you have done so far? root gives the nice explanation on your question.

  4. #4
    carlodelmundo is offline Member
    Join Date
    Aug 2008
    Posts
    31
    Rep Power
    0

    Default

    you could also use the Scanner class. (Google "scanner class java"). I find it useful that I can manipulate textfiles using scanner.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. file read
    By makpandian in forum New To Java
    Replies: 3
    Last Post: 12-11-2008, 05:02 AM
  2. Replies: 3
    Last Post: 08-24-2008, 02:51 PM
  3. 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
  4. Read file
    By tajinvillage in forum Threads and Synchronization
    Replies: 0
    Last Post: 01-29-2008, 10:10 AM
  5. read txt file
    By sureshsri1981 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-05-2007, 04:49 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
  •