mycp 补交作业

老师好:我昨天做完时已经是11点多了,错过了提交时间,希望用此篇博客弥补一下我的过失。

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/windows/Desktop/mycp.txt");
        OutputStreamWriter binary=new OutputStreamWriter(new FileOutputStream("/Users/windows/Desktop/mycp.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(" NO file exist");
    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println();
    try {

        FileReader file2=new FileReader("C:\Users\lenovo\zhuanyedajiesanshinian20155307\zhuanyedajiesanshinian20155307");
        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();
    }


}
}

mycp码云链接

posted @ 2017-06-02 10:49  专业打劫三十年  阅读(135)  评论(0编辑  收藏  举报