码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA_TransformIO

时间:2015-05-10 22:22:12      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 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 } //阻塞

 

JAVA_TransformIO

标签:

原文地址:http://www.cnblogs.com/roger-h/p/4493108.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!