import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class MyTest {
public static void main(String[] args) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream("abc.jpg"));
OutputStream out = new BufferedOutputStream(new FileOutputStream("dest.jpg"));
int b;
while ((b = in.read()) != -1)
out.write(b);
public class MyTest {
public static void main(String[] args) throws IOException {
try(InputStream in = new BufferedInputStream(new FileInputStream("abc.jpg"));
OutputStream out = new BufferedOutputStream(new FileOutputStream("dest.jpg")); //不管有无异常抛出,在try() 里的流在最后都会被关闭
)
int b;
while ((b = in.read()) != -1)
out.write(b);
}
}