package com.qyl.test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
//字节转字符
public class Testa {
public static void main(String[] args) throws Exception {
FileInputStream file = new FileInputStream("C:/Users/Administrator/Desktop/input.txt");
InputStreamReader in = new InputStreamReader(file);
byte[] b = new byte[1024];
int len;
while ((len=in.read())!=-1) {
System.out.print((char)len);
}
in.close();
//字符转字节
OutputStream file = new FileOutputStream("C:/Users/Administrator/Desktop/input.txt", true);
OutputStreamWriter in = new OutputStreamWriter(file);
String str = "木兰当户织";
in.write(str);
in.close();
}
}
转换流
最新推荐文章于 2023-05-19 11:24:44 发布