public class PracticeDemo1 {
public static void main(String[] args) throws IOException {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("E:\\space saving.PNG"));
byte[] bys = new byte[13];
// int len = bis.read(bys);
int len;
// int i=0;
while((len=bis.read(bys))!=-1){
System.out.println(test(bys));
// i++;
// if(i==10){
// break;
// }
}
// System.out.println(test(bys));
bis.close();
}
public static String test(byte[]bys){
String str2 = "";
StringBuffer stringBuffer=new StringBuffer();
for (int i = 0; i < bys.length; i++) {
String str = Integer.toHexString((int) bys[i]);
String str1="";
if (bys[i] < 0&&str.length()>=2) {
str1 = str.substring(str.length() - 2);
}
if (i != bys.length - 1) {
if (bys[i] < 0) {
stringBuffer.append(str1).append(",");
} else {
stringBuffer.append(str).append(",");
}
} else {
if (bys[i] < 0) {
stringBuffer.append(str1);
} else {
stringBuffer.append(str);
}
}
}
return stringBuffer.toString();
}
}