java MyCP -xt XXX1.bin XXX2.txt 用来二进制文件把转化为文本文件(内容为十进制数字)java
提交测试代码和运行结果截图,加上学号水印,提交码云代码连接。git
须要提交博客和答辩app
import java.io.*; public class MyCP{ public static void main(String[] args) throws IOException { //输入十进制文本 String filepath = "G:/学习的zxy最美丽/java/zxyjava/lll/from.txt"; String s =dataInputStream(filepath); //将获得的二进制数存成文本 FileOutputStream fps = new FileOutputStream("G:/学习的zxy最美丽/java/zxyjava/lll/to.txt"); fps.write(s.getBytes()); fps.close(); } public static String dataInputStream(String filepath) throws IOException { File file = new File(filepath); DataInputStream dps = new DataInputStream(new FileInputStream(file)); StringBuilder byData = new StringBuilder(); byte bt = 0; for(int i=0;i<file.length();i++) {//返回一个字符串二进制的无符号整数 bt = dps.readByte();//按照字节读取 String str = Integer.toBinaryString(bt); if(str.length() == 1) { str = "0"+str; } byData.append(str.toUpperCase()); } return byData.toString(); } }