I'm trying to display whats in the file header which should be text (the rest of the file is binary) but when I print strtemp I get this:
strTemp: ??????
Here is the code.
String fileName = "test.file";
URI logUri = new File(fileName).getAbsoluteFile().toURI();
BufferedInputStream in = new BufferedInputStream(new FileInputStream(new File(logUri)));
byte[] btemp = new byte[14];
in.read(btemp);
String strtemp = "";
for(int i = 0; i < btemp.length; i+= 2) {
strtemp += String.valueOf((char)(((btemp[i]&0x00FF)<<8) + (btemp[i+1]&0x00FF)));
}
System.out.println("strTemp: " + strtemp);
How do I get strtemp to be whats in the file? and to display it properly?
new String(btemp)instead of your loop?