1: import java.io.FileInputStream;
2: import java.io.FileNotFoundException;
3: import java.io.FileOutputStream;
4: import java.io.IOException;
5: import java.io.InputStreamReader;
6: import java.io.OutputStreamWriter;
7: import java.io.UnsupportedEncodingException;
8:
9: /*
10: * Created on 16.06.2004
11: *
12: * To change the template for this generated file go to
13: * Window>Preferences>Java>Code Generation>Code and Comments
14: */
15:
16: /**
17: * @author rogo
18: *
19: * To change the template for this generated type comment go to
20: * Window>Preferences>Java>Code Generation>Code and Comments
21: */
22: public class CodeTest
23: {
24:
25: public static void main(String[] args)
26: {
27: try
28: {
29: // OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("test"),"ISO-8859-1");
30: // for(int i=0;i<256;++i)
31: // {
32: // writer.write((char)i);
33: // }
34: // writer.close();
35: FileOutputStream stream = new FileOutputStream("test");
36: for(int i=0;i<256;++i)
37: stream.write(i);
38: stream.close();
39: InputStreamReader reader = new InputStreamReader(new FileInputStream("test"),"MacCentralEurope");
40: char[] a = new char[256];
41: reader.read(a);
42: String text= new String(a);
43: // System.out.println(text);
44: for(int i=0;i<text.length();++i)
45: System.out.println(i+" "+(int)text.charAt(i)+" "+text.charAt(i));
46:
47: text=Convert.normanToUnicode(text);
48:
49: reader.close();
50: OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream("test2.txt"),"UTF-8");
51: writer.write(text);
52: writer.close();
53: } catch (UnsupportedEncodingException e)
54: {
55: // TODO Auto-generated catch block
56: e.printStackTrace();
57: } catch (FileNotFoundException e)
58: {
59: // TODO Auto-generated catch block
60: e.printStackTrace();
61: } catch (IOException e)
62: {
63: // TODO Auto-generated catch block
64: e.printStackTrace();
65: }
66: }
67: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>