public class Test01_修改标准输入输出流拷贝图片 { //开发中不推荐使用
public static void main(String[] args) throws IOException {
System.setIn(new FileInputStream("头像.jpg"));
System.setOut(new PrintStream("头像_copy.jpg"));
InputStream is = System.in;
PrintStream ps = System.out;
byte[] arr = new byte[1024];
int len;
while ((len = is.read(arr))!=-1){
ps.write(arr, 0, len);;
}
is.close();
ps.close();
}
} |
|