Re: Java Inflater problem decompressing packfile
- From
- madmarcos <fru574@my.utsa.edu>
- Date
- Apr 17, 2011, 00:40 UTC
- Message-ID
- <1303000824677-6280097.post@n2.nabble.com>
- In-Reply-To
- <1302969047343-6279183.post@n2.nabble.com>
someone on the Java forums asked if I knew that the file was being read completely before inflating. Well... I just assumed (yes, I know not a good thing to do). So here is my readFile code in case you want to see it:
public byte [] readFile(String fileName) {
byte [] input2 = null;
File tempPackInputFile2 = new File(fileName);
InputStream tempPackInputStream2;
try {
tempPackInputStream2 = new FileInputStream(tempPackInputFile2);
long tempPackLength2 = tempPackInputFile2.length();
input2 = new byte[(int) tempPackLength2];
// Read in the bytes
int offset2 = 0;
int numRead2 = 0;
while (offset2 < input2.length
&& (numRead2 = tempPackInputStream2.read(input2, offset2,
input2.length-offset2)) >= 0) {
offset2 += numRead2;
}
tempPackInputStream2.close();
} catch (Exception e) {
e.printStackTrace();
}
return input2;
}-- View this message in context: http://git.661346.n2.nabble.com/Java-Inflater-problem-decompressing-packfile-tp6278154p6280097.html Sent from the git mailing list archive at Nabble.com.