Results 1 to 1 of 1
  1. #1
    hyperkossan is offline Member
    Join Date
    Dec 2008
    Rep Power

    Default Problem with in InputStreamReader, pls help


    Im trying to create a program that handles I / 0. Basicly I want to write a string to a .txt file. But I am troubled by the fact that I cant read in ,, correctly from the text file..

    here is my program:

    import java.util.*;

    class IOtxt
    public static void main (String[] args)

    Scanner in = new Scanner (, "Cp850");
    String filelocation = in.nextLine ();

    FileOutputStream fos = new FileOutputStream(filelocation);
    OutputStreamWriter osw = new OutputStreamWriter(fos);
    BufferedWriter fout = new BufferedWriter(osw);

    fout.write (text); // my string of text
    fout.close ();

    FileInputStream fis = new FileInputStream(filelocation);
    InputStreamReader isr = new InputStreamReader(fis); // Ive tried to implement "Cp850", "ASCII" and "UTF8" here without result..
    BufferedReader ReadIn = new BufferedReader(isr);

    StringBuffer buffer = new StringBuffer();
    int ch;
    while ((ch = > -1)
    String s2 = buffer.toString();
    System.out.println (s2);


    catch (IOException e)
    System.out.println (e);


    I can write the letters into the textfile without problem when I implement "CP850" to Scanner.. but I cant read in into my console from the created textfile :(
    please help! :)
    Last edited by hyperkossan; 12-10-2008 at 09:53 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