package myPackage;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class fileStreamTest {
public static void main(String[] args){
try{
byte bWrite [] = {'A','B','C','D','E'};
OutputStream os = new FileOutputStream("C:/Users/xmcares/Desktop/test.txt");
for(int x=0; x<bWrite.length; x++) {
os.write(bWrite[x]);
}
os.close();
InputStream is = new FileInputStream("C:/Users/xmcares/Desktop/test.txt");
int size = is.available();
for(int i = 0; i<size; i++){
System.out.print((char)is.read() + " ");
}
is.close();
} catch(IOException e){
e.printStackTrace();
}
}
}
JAVA文件输入输出流
最新推荐文章于 2024-09-01 15:30:33 发布