Здравствуйте, я пытаюсь сделать компрессор для предметов, но я, кажется, не совсем понимаю, у меня есть оригинальный файл, который я тестирую, как (items.dat, idx), мой декомпрессор все хорошо распаковывает, но когда я использую свой компрессор затем проверить его на предмет дает мне ошибку.
java.io.EOFException
Extracted: 876 models!
at java.io.DataInputStream.readFully(Unknown Source)
at java.io.DataInputStream.readFully(Unknown Source)
at ModelRipper.decompress(ModelRipper.java:46)
at ModelRipper.main(ModelRipper.java:27)
моя строка 46:
Строка с методом
Мой метод распаковки:
public static void decompress() {
try {
GZIPInputStream gzipDataFile = new GZIPInputStream(new FileInputStream(signlink.findcachedir() + userInput + ".dat"));
DataInputStream dataFile = new DataInputStream(gzipDataFile);
GZIPInputStream gzipIndexFile = new GZIPInputStream(new FileInputStream(signlink.findcachedir() + userInput + ".idx"));
DataInputStream indexFile = new DataInputStream(gzipIndexFile);
int length = indexFile.readInt();
for(int i = 0; i < length; i++) {
int id = indexFile.readInt();
int invlength = indexFile.readInt();
byte[] data = new byte[invlength];
dataFile.readFully(data);
System.out.println(id);
System.out.println(invlength);
Model.method460(data, id);
FileOutputStream fos = new FileOutputStream("./MODELS1/"+id+".dat");
modelsExtracted++;
fos.write(data);
fos.flush();
fos.close();
}
indexFile.close();
dataFile.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Мой метод сжатия:
public static void compress() throws FileNotFoundException, IOException {
try {
File file = new File("./MODELS/");
GZIPOutputStream gzipDataFile = new GZIPOutputStream(new FileOutputStream("./" + userInput + ".dat"));
DataOutputStream dataFile = new DataOutputStream(gzipDataFile);
GZIPOutputStream gzipIndexFile = new GZIPOutputStream(new FileOutputStream("./" + userInput + ".idx"));
DataOutputStream indexFile = new DataOutputStream(gzipIndexFile);
File[] fileArray = file.listFiles();
for (int y = 0; y < fileArray.length; y++) {
String s = fileArray[y].getName();
byte[] buffer = ReadFile("./MODELS/" + s);
modelsExtracted++;
int invlength = (int) fileArray[y].length();
int id = Integer.parseInt(getFileNameWithoutExtension(s));
indexFile.writeInt(id);
//indexFile.flush();
indexFile.writeInt(invlength);
indexFile.flush();
System.out.println(id);
System.out.println(invlength);
dataFile.write(buffer);
dataFile.flush();
}
indexFile.close();
dataFile.close();
} catch (Exception e) {
e.printStackTrace();
}
}