JAVA_TransformIO

 1 import java.io.*;
 2 public class TestTransForm1 {
 3   public static void main(String[] args) {
 4     try {
 5       OutputStreamWriter osw = new OutputStreamWriter(
 6            new FileOutputStream("d:\\bak\\char.txt"));
 7       osw.write("mircosoftibmsunapplehp");
 8       System.out.println(osw.getEncoding());
 9       osw.close();
10       osw = new OutputStreamWriter(
11                                       new FileOutputStream("d:\\bak\\char.txt", true),
12                                       "ISO8859_1"); // latin-1
13       osw.write("mircosoftibmsunapplehp");
14       System.out.println(osw.getEncoding());
15       osw.close();
16     } catch (IOException e) {
17       e.printStackTrace();
18     }
19   }
20 }
 1 import java.io.*;
 2 public class TestTransForm2 {
 3   public static void main(String args[]) {
 4     InputStreamReader isr =
 5             new InputStreamReader(System.in);
 6     BufferedReader br = new BufferedReader(isr);
 7     String s = null;
 8     try {
 9       s = br.readLine();
10       while(s!=null){
11         if(s.equalsIgnoreCase("exit")) break;
12         System.out.println(s.toUpperCase());
13         s = br.readLine();
14       }
15       br.close();
16     } catch (IOException e) {
17       e.printStackTrace();
18     }
19   }
20 } //阻塞
时间: 2024-08-18 10:06:55

JAVA_TransformIO的相关文章