---------------------- android培训、java培训、期待与您交流! --------------------
package IO;
import java.io.*;
import static Test_purview.print.*;
public class IOSimpleTest {
public static void main(String[] args){
FileInputStream n = null ;//字节输入流
FileOutputStream o = null;//输出字节流
FileReader r = null;
FileWriter w = null;
//创建于一个输入字节流
try{
n = new FileInputStream("D:\\javaProgram\\Child.java");
}catch(Exception e){
e.printStackTrace();
}
// 创建一个输出字节流
try{
o = new FileOutputStream("D:\\javaProgram\\Cat.java");
}catch(Exception e){
print("Some Exception Occured!");
}
// 创建一个输入字符流
try{
r = new FileReader("D:\\javaProgram\\Child.java");
}catch(Exception e ){
System.out.print("Some Exception Occured!");
}
// 创建一个输出字符流
try{
w = new FileWriter("D:\\javaProgram\\FileWriter.java");
}catch(Exception e){
print("This File is not found!");
}
int a = 0;
int b = 0;
try {
while((b = n.read())!=-1){
System.out.print((char)b);
// print(n.read());
o.write(b);
}
while ((a = r.read())!=-1) {
System.out.print((char)a);
w.write(a);
}
o.close();
n.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
---------------------- android培训、java培训、期待与您交流! ----------------------