标签:val tput linux 实现 图片 ima 编写 throw file
java MyCP -xt XXX1.bin XXX2.txt 用来二进制文件把转化为文本文件(内容为十进制数字)
import java.io.*;
/**
*Created by xiang on 2018/6/10.
*/
public class MyCP {
public static void dumpToTwo(InputStream src, OutputStream dest)
throws IOException {
try (InputStream input = src; OutputStream output = dest) {
byte[] data = new byte[1];
int length;
while ((length = input.read(data)) != -1) {
String str = Integer.toBinaryString((data[0]&0xFF)+0x100).substring(1);//Byte.parseByte(Integer.toBinaryString(num)); //转换为二进制文件
data[0] = Byte.parseByte(str);
output.write(data, 0, length);
}
}
}
public static void dumpToTen(InputStream src, OutputStream dest)
throws IOException {
try (InputStream input = src; OutputStream output = dest) {
byte[] data = new byte[1];
int length;
while ((length = input.read(data)) != -1) {
data[0] = Byte.parseByte(String.valueOf(data[0]),10); //转换为十进制文件
output.write(data, 0, length);
}
}
}
public static void main(String[] args) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream("D:/Java/from.txt");
fos = new FileOutputStream("D:/Java/to.txt");
dumpToTen(fis, fos);
}catch(Exception e) {
System.out.println(e);
}
}
}
标签:val tput linux 实现 图片 ima 编写 throw file
原文地址:https://www.cnblogs.com/musea/p/9164723.html