Results 1 to 1 of 1
- 12-10-2008, 08:50 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 1
- Rep Power
- 0
Problem with ÅÄÖ in InputStreamReader, pls help
Hello!
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.io.*;
import java.util.*;
class IOtxt
{
public static void main (String[] args)
{
try
{
Scanner in = new Scanner (System.in, "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 = ReadIn.read()) > -1)
{
buffer.append((char)ch);
}
ReadIn.close();
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 08:53 PM.


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks