Created
August 15, 2012 14:39
-
-
Save jlitewski/3360668 to your computer and use it in GitHub Desktop.
Dirty byte decompression based on grouping like numbers together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.DataInputStream; | |
import java.io.BufferedInputStream; | |
import java.io.FileInputStream; | |
import java.util.zip.GZIPInputStream; | |
public class TestCodeDirtyDecompression { | |
public static void main(String[] args) { | |
long start = System.currentTimeMillis(); | |
int[][][] array = new int[4][8][4]; | |
File file = new File("test.chunk"); | |
try { | |
DataInputStream stream = new DataInputStream(new BufferedInputStream( | |
new GZIPInputStream(new FileInputStream(file)), 2056)); | |
int repeat = 0; | |
int repeater = -1; | |
for(int c = 0; c < 8; c++) { //y | |
for(int b = 0; b < 4; b++) { //z | |
for(int a = 0; a < 4; a++) { //x | |
if(repeat > 0) { | |
array[a][c][b] = repeater; | |
repeat--; | |
continue; | |
} | |
int read = stream.readInt(); | |
if(read == -1) { | |
repeater = stream.readInt(); | |
repeat = stream.readInt(); | |
array[a][c][b] = repeater; | |
repeat--; | |
continue; | |
} else { | |
array[a][c][b] = read; | |
} | |
} | |
} | |
} | |
long end = System.currentTimeMillis(); | |
/* | |
for(int c = 0; c < 8; c++) { //y | |
for(int b = 0; b < 4; b++) { //z | |
for(int a = 0; a < 4; a++) { //x | |
System.out.println(array[a][c][b]); | |
} | |
} | |
} | |
*/ | |
System.out.println("Done in "+(end-start)+" ms"); | |
} catch(Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment