20155311高梓云补交的Mypc课下实践
老师,由于我自己的疏忽导致没有及时交上这次作业。这是我的代码和截图。
```/**import java.io.*;
import java.lang.*;
import java.util.Scanner;
public class MyCP {
public static void main(String args[]) {
try {
FileReader file=new FileReader("/Users/mac/Desktop/input.txt");
OutputStreamWriter binary=new OutputStreamWriter(new FileOutputStream("/Users/mac/Desktop/output.txt"));
BufferedReader br=new BufferedReader(file);
String strs=null;
while ((strs=br.readLine())!=null) {
System.out.println(strs);
int num=Integer.parseInt(strs);
//for (int i=0;i<strs.length();i++){
binary.write(Integer.toBinaryString(num));
System.out.print(Integer.toBinaryString(num));
//}
}
binary.close();
} catch (FileNotFoundException e) {
System.out.println("file doesn't exist");
} catch (IOException e) {
e.printStackTrace();
}
System.out.println();
try {
FileReader file2=new FileReader("C:\\Users\\LJY\\IdeaProjects\\Stream\\src\\test1.bin");
OutputStreamWriter test=new OutputStreamWriter(new FileOutputStream("C:\\Users\\LJY\\IdeaProjects\\Stream\\src\\test2.txt"));
BufferedReader br2=new BufferedReader(file2);
String strs2=null;
while ((strs2=br2.readLine())!=null) {
System.out.println(strs2);
//int num2=Integer.parseInt(strs2);
//for (int i=0;i<strs.length();i++){
test.write(Integer.parseInt(strs2,2));
System.out.println(Integer.parseInt(strs2,2));
//}
}
test.close();
} catch (FileNotFoundException e) {
System.out.println("file doesn't exist");
} catch (IOException e) {
e.printStackTrace();
}
}
}
![](http://images2015.cnblogs.com/blog/1071541/201706/1071541-20170602004824446-186640053.png)
![](http://images2015.cnblogs.com/blog/1071541/201706/1071541-20170602004830586-877304072.png)
![](http://images2015.cnblogs.com/blog/1071541/201706/1071541-20170602004840321-633488960.png)
这是我的博客链接
http://git.oschina.net/bestiisjava2017/gaoziyun20155311/blob/master/javadashabi/MyCP副本.java?dir=0&filepath=javadashabi%2FMyCP副本.java&oid=44d1a5ef0efebce42cc42b3d5269505326599ac2&sha=8fad53e60772c84762b098eec46eccac4245887f