IO之转换流举例
2024-08-30 18:30:43
import java.io.*;
public class TestTransForm1 {
public static void main(String[] args) {
try {
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream("d:\\bak\\char.txt"));
osw.write("mircosoftibmsunapplehp");
System.out.println(osw.getEncoding());
osw.close();
osw = new OutputStreamWriter(
new FileOutputStream("d:\\bak\\char.txt", true),
"ISO8859_1"); // latin-1
osw.write("mircosoftibmsunapplehp");
System.out.println(osw.getEncoding());
osw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.*;
public class TestTransForm2 {
public static void main(String args[]) {
InputStreamReader isr =
new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String s = null;
try {
s = br.readLine();
while(s!=null){
if(s.equalsIgnoreCase("exit")) break;
System.out.println(s.toUpperCase());
s = br.readLine();
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
最新文章
- WinForm------TextEdit控件内容字体变*号
- Couldn't open file on client side, trying server side 错误解决
- post 与 get 在转码的区别
- 转 用 AXIOM 促进 XML 处理
- ASP长文章分页的两个方法,函数
- python上下文管理器及with语句
- jrae源码解析(一)
- java Json字符串转List<;Map>;类型
- Java 开机启动
- ubantu下su命令Authentication failure失败的解决方式
- 【Tomcat】性能优化
- 深入理解Git (一) - 元数据
- MySql关联子查询
- Oracle 默认的driectory 目录
- Springmvc ajax跨域请求处理
- Linux Mysql 卸载
- bootstrap-table设置某列序号自增
- java实现数据库分页
- Pix mesa 自动化测试
- Trident学习笔记(二)
热门文章
- RestTemplate中headers中添加Host不生效
- python 面向对象七 property() 函数和@property 装饰符
- bzoj 2151: 种树【贪心+堆】
- bzoj 4823: [Cqoi2017]老C的方块【最大权闭合子图】
- Tensor Operation
- Java标准输入流system.in报错: java.util.NoSuchElementException解决方法
- Qt事件系统之三:键盘事件
- 牛客小白月赛5-I-区间(差分求前缀和+一次暴力统计)
- 使用dubbox开发REST应用
- Web自动化测试框架-PO模式