Results 1 to 6 of 6
  1. #1
    johnes.jk is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default file read problems in java

    i tried to read different text files continously using java.
    The first txt file is read correctly
    From 2nd file ASCII characters are included in file stream

    Can anyone solve the problem

  2. #2
    paras is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

    Default

    what do you mean by continously?
    and what classes are you using to read the files

  3. #3
    johnes.jk is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Thumbs up

    a file after another

    File file = new File(filename); // different file name come in different exections

    FileInputStream fis = null;
    BufferedInputStream bis = null;
    DataInputStream dis = null;
    fis = new FileInputStream(file);
    bis = new BufferedInputStream(fis);
    dis = new DataInputStream(bis);

    while (dis.available() != 0)
    {
    String nameVal=dis.readLine();
    }

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Well you're only reading from one file there, and not doing anything with it. You need to clarify what your question/problem is.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  5. #5
    paras is offline Member
    Join Date
    Apr 2009
    Posts
    8
    Rep Power
    0

    Default

    are you closing all your streams after using them?

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

    Default

    It's better to show your whole code, if it's not too long, here.

    1. How did you start different executions.
    2. What's the content of the first file, you said that only second file contain ASCII, so on the first one?

Similar Threads

  1. help to read .pst file through java
    By umadas in forum Advanced Java
    Replies: 2
    Last Post: 12-19-2010, 04:32 AM
  2. How to read Excel file with java
    By chetan-24 in forum New To Java
    Replies: 5
    Last Post: 04-22-2009, 05:11 PM
  3. Executable java to read and write to a txt file
    By njoymirror in forum New To Java
    Replies: 2
    Last Post: 03-21-2009, 01:19 AM
  4. File read/write problems
    By p900128 in forum New To Java
    Replies: 4
    Last Post: 06-27-2008, 12:15 AM
  5. 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, 09:13 AM

Posting Permissions

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