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
    7

    Default file read without whitspaces

    i write a program to read text file
    but it also read white spaces.

    i could'nt read without whit spaces.

    help me.

    my test file contain some integer values.
    i want to read and assign with two-dimensional array.

    plz help me.

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    trim()? See the String API docs.

    Otherwise, post a small example of the text file, a (much) better description of what you want to acheive (with examples), and the code you're using.

  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

    Using all Java streams you can read lines of the text file. After that you need to process as you want. So here we need a best explanation about your question.

  4. #4
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Yes, better explaination - plus small sample of the file.

    String.split() will split on whitespace, Scanner will read ints, we can also do String[] line = readline() with a string.split on the resulting String.

    Several approaches available, need better problem description.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  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. cannot read file while compiling!!!
    By AMIT TAYADE in forum New To Java
    Replies: 11
    Last Post: 08-23-2008, 01:02 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
  •