git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Java Inflater problem decompressing packfile

From
Mmadmarcos <fru574@my.utsa.edu>
Date
Apr 17, 2011, 04:02 UTC
Message-ID
<1303012970295-6280285.post@n2.nabble.com>
In-Reply-To
<1303000824677-6280097.post@n2.nabble.com>

my entire testing class is below. just change the file path string in the first line in test4.

package server_test2;

import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.util.zip.Inflater;

public class InflaterTest2 {
	public InflaterTest2() {
	}
	public void test4() {
		try {
			byte[] packFile = readFile2("/Users/marcos/GitProxyCache/jedit.pack");
			byte [] packDataWindow = new byte[8000];
			//the below object is the .classpath blob. works fine
			System.arraycopy(packFile, 4828 + 2, packDataWindow, 0,
packDataWindow.length); 
			//the below object is the .project blob. works fine
			//System.arraycopy(packFile, 4978 + 2, packDataWindow, 0,
packDataWindow.length); 
			
			//the below object is the top-level tree. works fine
			//System.arraycopy(packFile, 5171 + 2, packDataWindow, 0,
packDataWindow.length); 
			//the below object is source code notes blob. works fine
			//System.arraycopy(packFile, 5760 + 3, packDataWindow, 0,
packDataWindow.length); 
			//the below object is a build file blob. works fine
			//System.arraycopy(packFile, 8619, packDataWindow, 0,
packDataWindow.length); 
			
			//THE BELOW OBJECT FAILS TO INFLATE
			//IT CAUSES an "incorrect data check" error
       		//Object starts at index 9470
       		//Type = 3, Decompressed size = 51060 (uses 2 extra size bytes)
			//System.arraycopy(packFile, 9470 + 3, packDataWindow, 0,
packDataWindow.length); 
			Inflater decompresser = new Inflater();
			decompresser.setInput(packDataWindow, 0, packDataWindow.length);
			byte[] result = new byte[60000];
			int resultLength = 0;
			resultLength = decompresser.inflate(result);
			
			String outputString = new String(result, 0, resultLength, "UTF-8");
			System.out.println(outputString);
			System.out.println("------- End Decompressed Output -------");
			int numCompressed = (int) decompresser.getBytesRead();
			System.out.println("# Bytes Compressed: " + numCompressed);
			decompresser.end();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public byte [] readFile2(String fileName) {
		byte [] input2 = null;
	    File tempPackInputFile2 = new File(fileName);
		DataInputStream tempPackInputStream2;
		try {
			tempPackInputStream2 = new DataInputStream(new
FileInputStream(tempPackInputFile2));
			long tempPackLength2 = tempPackInputFile2.length();
			input2 = new byte[(int) tempPackLength2];
			tempPackInputStream2.readFully(input2);
		    tempPackInputStream2.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    return input2;
	}
	public static void main(String[] args) {
		InflaterTest2 app = new InflaterTest2();
		app.test4();
		System.out.println("Done.");
	}
}

-- View this message in context: http://git.661346.n2.nabble.com/Java-Inflater-problem-decompressing-packfile-tp6278154p6280285.html Sent from the git mailing list archive at Nabble.com.

Previous: madmarcosNext: madmarcos
Message 8 of 10 in “Java Inflater problem decompressing packfile”
  1. madmarcosApr 16, 2011
  2. Jeff KingApr 16, 2011
  3. madmarcosApr 16, 2011
  4. madmarcosApr 16, 2011
  5. madmarcosApr 16, 2011
  6. madmarcosApr 16, 2011
  7. madmarcosApr 17, 2011
  8. madmarcosApr 17, 2011
  9. madmarcosApr 17, 2011
  10. Jeff KingApr 17, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.