Results 1 to 3 of 3

Thread: Binary IO help

  1. #1
    kosok is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Default Binary IO help

    IO always gives me trouble...

    Anyway, I want to use FileOutputStream to save some data to a file. But the integers that i'm trying to write are 4 or 5 digits long, and it seems that only values up to 255 can be written without it messing up.

    So , how do I use FileOutputStream to save integers with 4 or 5 digits, and then recall them using FileInputStream?

  2. #2
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    396
    Rep Power
    6

    Default

    instead of fileoutputstream you have to use filewriter class to write 4 or 5 digit values.

    after stream creation
    use function like writeline();

    it certain will work.

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
    BufferedWriter bw = new BufferedWriter(
                        new OutputStreamWriter(
                        new FileOutputStream(file)));
    // use [i]write(String s, int off, int len)[/i] method
    
    BufferedReader br = new BufferedReader(
                        new InputStreamReader(
                        new FileInputStream(file)));
    // use [i]readLine[/i] method

Similar Threads

  1. Binary Output Help!
    By Storm20 in forum New To Java
    Replies: 1
    Last Post: 12-16-2008, 02:53 AM
  2. Binary text
    By bizmut in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-24-2008, 02:50 AM
  3. get binary value
    By rushenas in forum New To Java
    Replies: 2
    Last Post: 06-14-2008, 01:51 PM
  4. binary conversion
    By thamizhisai in forum New To Java
    Replies: 3
    Last Post: 04-29-2008, 11:55 AM
  5. Binary Addition
    By Deo Favente in forum Advanced Java
    Replies: 11
    Last Post: 04-24-2008, 05:34 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
  •