public class Stream {
public static void main(String[] args) throws Exception {
File ff = new File("E:/test/aaa.txt");
File f = new File("E:/test/aaaa.txt");
InputStream ii = null;
OutputStream oo = null;
try {
ii = new FileInputStream(ff);
oo = new FileOutputStream(f,false);
int size = 0;
byte[] buf = new byte[1024];
System.out.println(buf.toString());
while ((size = ii.read(buf)) != -1) {
oo.write(buf,0,size);
System.out.println(size);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
finally
{
oo.flush();
oo.close();
ii.close();
}
}
public static void main(String[] args) throws Exception {
File ff = new File("E:/test/aaa.txt");
File f = new File("E:/test/aaaa.txt");
InputStream ii = null;
OutputStream oo = null;
try {
ii = new FileInputStream(ff);
oo = new FileOutputStream(f,false);
int size = 0;
byte[] buf = new byte[1024];
System.out.println(buf.toString());
while ((size = ii.read(buf)) != -1) {
oo.write(buf,0,size);
System.out.println(size);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
finally
{
oo.flush();
oo.close();
ii.close();
}
}
}
E:/test/aaa.txt
E:/test/aaaa.txt
这两个文件都应该是存在的