FileInputStream与FileOutputStream的使用
public class FileInputstrem {
public static void main(String[] args) {
try {
FileInputStream input=new FileInputStream(new File("D:\\a.txt"));
byte[] bytes= {1,2,3,4,5,6,7,8,9,0};
while(-1!=input.read(bytes)) {
System.out.println(new String(bytes).toString());
}
input.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public class FileOutputstrem {
public static void main(String[] args) {
try {
FileOutputStream out=new FileOutputStream(new File("D:\\b.txt"));
byte[] bytes= {1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9};
out.write(bytes);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}