【发布时间】:2014-08-20 11:50:01
【问题描述】:
我试图创建一个必须对文件内容进行解密的程序。
我的代码如下,问题是在我调用decompresser.inflate(result) 之后,此方法中不再执行任何操作。我是否必须通过另一个字段替换结果或错误在哪里?
//The string with the not yet decompressed content is converted into a byte array Content was earlier defined and initialised
byte[] notDeComPresCo = new byte[content.length()];
for (int i = 0; i < content.length(); i++) {
notDeComPresCo[i] = content.substring(i, i + 1).getBytes()[0];
}
//Until here the programm works as I want, then the problem starts:
//A new inflater is contructed to decompress the byte array into an decompressed byte array
Inflater decompressor = new Inflater();
decompressor.setInput(notDeComPresCo, 0, notDeComPresCo.length);
byte[] result = new byte[content.length()];
try {
System.out.println("This is printed");
int decompressedDataLength = decompressor.inflate(result);
System.out.println("This system.out.println - command is not printed");
decompressor.end();
String x = new String(result, 0, decompressedDataLength, "UTF-8");
} catch (DataFormatException e) {
throw new InvalidGitObjectFileException("The content could not be decompressed.");
}
控制台中没有错误,该方法在到达System.out.println("This system.out.println - command is not printed")之前结束。
【问题讨论】:
-
您等了多长时间?
InvalidGitObjectFileException被抛出了吗? -
是的,对不起,我错过了……但它被抛出在调用此方法的另一个方法中!
-
Decompressor 应该解压,Inflator 应该充气......不过这不是主题
标签: java compression inflate