2 Star 5 Fork 0

qinghuan1337 / 20175318_JAVA

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
MyOD.java 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
qinghuan1337 提交于 2019-04-28 21:13 . add MyCP and MyOD
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* @author lihaoran
*/
@SuppressWarnings("ALL")
public class MyOD {
public static String format(byte []bt){
int line=0 ;
StringBuilder buf=new StringBuilder() ;
for(byte d:bt){
if(line%16==0) {
buf.append(String.format("%05x: ", line)) ;
}
buf.append(String.format("%02x ", d)) ;
line++ ;
if(line%16==0) {
buf.append("\n");
}
}
buf.append("\n") ;
return buf.toString();
}
public static byte[] readFile(String file) throws IOException{
InputStream is=new FileInputStream(file) ;
int length=is.available() ;
byte[] bt = new byte[length];
is.read(bt) ;
return bt;
}
public static void main(String[]agrs) throws IOException{
byte []bt=MyOD.readFile("D:/Java/OD.txt");
String hexData=MyOD.format(bt) ;
System.out.println(hexData);
}
}
Java
1
https://gitee.com/lhr0321/20175318_JAVA.git
git@gitee.com:lhr0321/20175318_JAVA.git
lhr0321
20175318_JAVA
20175318_JAVA
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891