i want to create a binary file that contain a check of directory files like this one i tried reading this file using this code
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class ZeroFileDecryptor {
public static void main(String[] args) {
// TODO Auto-generated method stub
String file_name = "0";
try {
FileInputStream fos = new FileInputStream(file_name);
DataInputStream os = new DataInputStream(fos);
System.out.println("os read");
// Header
System.out.println(os.readShort());
System.out.println(os.readInt());
// 0 file size
System.out.println(os.readInt());
// separator
System.out.println(os.readShort());
// 1 folder path - custom description
System.out.println(os.readUTF());
os.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
it contain a header, the file size, a separator (not sure), the path to the file containing the files, a checksum crc32(not sure) and a loop throw the files filename - file extension - filename - file checksum crc32(not sure) when it come to read the filename using os.readUTF() i got a java.io.UTFDataFormatException. is that the right way to parse this file ? how can i get the missing value ? how can i read the filename without the error ?