Results 1 to 4 of 4
  1. #1
    artemff is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Default How correctly open text file?

    I try such:
    DataInputStream dis = new DataInputStream(getClass().getResourceAsStream("e:/Others/c.txt"));
    StringBuffer strBuff = new StringBuffer();
    int ch = 0;
    try {
    while ((ch = dis.read()) != -1) {
    strBuff.append((char ) ((ch >= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch));
    }
    dis.close();
    } catch (Exception e) {
    System.err.println("ERROR in getText() " + e);
    }

    But when I am tracing this code, It happens transferring to string with exception. Maybe i insert incorrect file path??

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

  3. #3
    artemff is offline Member
    Join Date
    Dec 2009
    Posts
    41
    Rep Power
    0

    Question

    Fubarable,
    How link Reader with file? Because in list of functions it isn't such function.
    Last edited by artemff; 12-23-2009 at 07:27 PM.

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

Similar Threads

  1. Replies: 8
    Last Post: 11-06-2009, 07:52 AM
  2. Different Files Open in File -> Open Workspace
    By mgm2010 in forum JCreator
    Replies: 0
    Last Post: 04-11-2009, 03:14 PM
  3. find and replace text from a text file
    By gezzel in forum New To Java
    Replies: 2
    Last Post: 09-19-2008, 05:04 PM
  4. To open an image file such as Jpeg file using JAva Program
    By itmani2020 in forum Advanced Java
    Replies: 10
    Last Post: 07-11-2008, 10:57 AM
  5. Is it possible to open a txt file?
    By jason27131 in forum New To Java
    Replies: 20
    Last Post: 08-07-2007, 02:24 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
  •