I am trying to convert long to bytes because I want to write the time stamp in seconds in a file. Belwo are the method wich I am using to convert long to bytes[] and how I write them into a file..
What I am getting from the following line:
bos.write( ( CSysUtils.longToBytes(CSysUtils.getTSMilli()) ) );
is an unreadable code/format:
code:
public static long getTSSec() {
Log.w(TAG, CSubTag.bullet("getTSSec"));
return System.currentTimeMillis()/1000;
}
public static byte[] longToBytes(long l) {
byte[] result = new byte[8];
for (int i = 7; i >= 0; i--) {
result[i] = (byte)(l & 0xFF);
l >>= 8;
}
return result;
}
write to a file:
fos = new FileOutputStream(file, true);
bos = new BufferedOutputStream(fos);
bos.write( ( CSysUtils.longToBytes(CSysUtils.getTSSec()) ) );