ArrayList changing when receiving info from socket Java - java

I am getting this bug which I just can't imagine the cause for. I have a receiver class which receives packets, within which is an ArrayList. No, the packets don't have an ArrayList; the class has one. When I receive a new packet, the ArrayList is altered, but before I alter it. In fact, before I even read the data from the packet into the object I am using the data. Not only that, but the ArrayList is changing all the objects within the array to the equivalent of the object which is created from the data in a later instruction...
Method which is producing the weird behaviour:
public void processPackets() {
byte[] buffer = new byte[1024];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
try {
while(true) {
System.out.println("Start: " + outBuffer);
socket.receive(packet);
System.out.println("Before: " + outBuffer);
// Find out where the packets are coming from
if (sendHost == null) {
sendHost = packet.getAddress();
sendPort = packet.getPort();
}
// Grab the data from the packet
PacketInfo data = new PacketInfo(packet.getData());
System.out.println("Found: " + data);
if (this.packetWithinWindow(data.getSequenceNumber())) {
outBuffer.add(data);
System.out.println("After: " + outBuffer);
}
ackThePacket(data);
if (processData()) {break;}; // Returns true after last packet processed
System.out.println("End: " + outBuffer);
}
} catch (IOException ioe) {
System.err.println(ioe);
System.exit(1);
}
}
Given that outBuffer is an ArrayList<PacketInfo> and PacketInfo.toString() returns a sequence number and a list of the first 20 bytes, this is a sample of the weird behaviour that is then printed to the console (after several cycles through the code where outBuffer starts empty):
Start: []
Before: []
Found:
2 [-120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120]
After: [
2 [-120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120]]
End: [
2 [-120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120]]
Start: [
2 [-120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120, 8, 0, 2, -120]]
Before: [
1 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 65, 0, 76, 0, 71, 68, 70, 68, 48]]
Found:
1 [0, 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exing me so any help is appreciated. If it's any help, this is compiled using Java 6.

Related

How to read the TypedArray data in Android?

I'm new to Android and still following some tutorials. One tut is about TypedArray for storing the image information.
MainActivity.java
package com.example.materialme;
import androidx.appcompat.app.AppCompatActivity;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.util.Log;
import java.util.ArrayList;
import java.util.Arrays;
public class MainActivity extends AppCompatActivity {
private static final String TAG = MainActivity.class.getSimpleName();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TypedArray sportsImageResources = getResources().obtainTypedArray(R.array.sports_images);
Log.d(TAG, "sportImageResources: " + sportsImageResources);
sportsImageResources.recycle();
}
}
strings.xml
<resources>
<array name="sports_images">
<item>#drawable/img_baseball</item>
<item>#drawable/img_badminton</item>
<item>#drawable/img_basketball</item>
<item>#drawable/img_bowling</item>
<item>#drawable/img_cycling</item>
<item>#drawable/img_golf</item>
<item>#drawable/img_running</item>
<item>#drawable/img_soccer</item>
<item>#drawable/img_swimming</item>
<item>#drawable/img_tabletennis</item>
<item>#drawable/img_tennis</item>
</array>
</resources>
When I see in logcat, the values of TypedArray sportsImageResources are
[3, 179, 6, 2131165272, 0, 0, 3, 178, 6, 2131165271, 0, 0, 3, 180, 6, 2131165273, 0, 0, 3, 181, 6, 2131165274, 0, 0, 3, 182, 6, 2131165275, 0, 0, 3, 183, 6, 2131165276, 0, 0, 3, 184, 6, 2131165277, 0, 0, 3, 185, 6, 2131165278, 0, 0, 3, 186, 6, 2131165279, 0, 0, 3, 187, 6, 2131165280, 0, 0, 3, 188, 6, 2131165281, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0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 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 2131558747, 6, 2131558747, 1073742848, 0, 1, 2131558746, 6, 2131558746, 1073742848, 0, 28, -1, 1, 17170443, 1073742848, 0, 3, 193, 6, 2131165294, 1073742848, 0, 3, 27, 6, 0, 1073742848, 0, 18, -1, 6, 0, 1073742848, 0, 18, 0, 6, 0, 1073742848, 0, 18, 0, 6, 0, 1073742848, 0, 0, 0, -1, 0, 1073742848, 0, 0, 0, -1, 0, 1073742848, 0, 0, 0, -1, 0, 1073742848, 0, 0, 0, -1, 0, 1073742848, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 18, 0, 6, 0, 1073742848, 0]
How to read this data?
May be this example will help you.
TypedArray sportsimgs = getResources().obtainTypedArray(R.array.random_imgs);
// get resource ID by index
sportsimgs .getResourceId(i, -1)
// or set you ImageView's resource to the id
mImgView1.setImageResource(sportsimgs .getResourceId(i, -1));
// recycle the array
sportsimgs .recycle();

getting the binary data represented by the hexadecimal string back in java vs python

I know that in python binascii.unhexlify(initValue)
return the binary data represented by the hexadecimal string back.
I am trying to convert binascii.unhexlify(initValue) to java.
I tried the following code lines in java but I am getting different results then the code in python:
DatatypeConverter.parseHexBinary(value);
I run the following example:
my input - hexadecimal string:
value = '270000f31d32d1051400000000000000000000000006000000000000000000000000000000000000'
when running in python:
result = binascii.unhexlify(value)
I am getting:
result = "'\x00\x00\xf3\x1d2\xd1\x05\x14\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
when running in java:
byte[] bytes = DatatypeConverter.parseHexBinary(value);
I am getting:
bytes = [39, 0, 0, -13, 29, 50, -47, 5, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
1.why I am getting different results?
why do I get the output in python with '\' marks?
The first hex of your result, "'" is exactly 39 in signed char. In python, you can use built-in function ord("'") to get 39.
You can probably get what you want in this python code
value = '270000f31d32d1051400000000000000000000000006000000000000000000000000000000000000'
result = binascii.unhexlify(value)
bytes = [ord(x) for x in result]
You will be getting this unsigned char:
[39, 0, 0, 243, 29, 50, 209, 5, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Java adding a 2D arraylist to a list of 2D arraylists

I am creating a map system for my game which requires me at a few stages to replace the old 2D array map with another. What I wanted to do is add all the 2D arraylist maps into a List of these 2D arraylists. However, what I found difficult was that when I wanted to retrieve said map, the .get method would not give me the correct data, as it you would try to pull the first item of that arraylist which in this case would be null. Thus the program threw me nullpointerexceptions.
private int[][] mapArray;
private List<int[][]> maps = new ArrayList<>();
mapArray = new int[][]{
{0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 9, 1, 1, 7, 7, 7, 7, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{7, 7, 7, 7, 5, 8, 8, 8, 4, 6, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{4, 4, 4, 4, 4, 8, 8, 8, 4, 4, 6, 7, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{4, 4, 4, 4, 4, 8, 8, 8, 4, 4, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
maps.add(mapArray);
When I sout maps.get(0) I get the following:
[[I#58838f3f
If I have two items, it will show up like this:
[[[I#58838f3f, [[I#59a60155]
Ideally I want it to be added like this:
[I#58838f3f, I#58838f3f]
I am just unsure how to do this. Any help would be appreciated!
I might have overlooked something obvious, probably is the case!
Much obliged
You seem to be confusing the output of converting your map (or the list of maps) to string (which is what happens when you try to print them) - with what actual value there are there.
Because ArrayList like most Java container formats have nice toString() implementations that get automatically called when trying to print them, you'd get something that "looks like an array" in the output. So for example when printing an array list containing two strings, it might look like this: [a, b].
Arrays don't have such nice formatters, because they aren't really objects (they are "primitive types") and so print them gets you their address and some Java byte code that describes their type (if you can understand Java byte code), so an array of integers will look like this: [I#<address> while an two dimensional array of bytes will look like this: [[B#<address>, and so on.
In regards to your original question, the code seems to work well for me. Here is an example program:
import java.util.ArrayList;
public class Test2D {
public static void main(String... args) {
ArrayList<int[][]> maps = new ArrayList<>();
maps.add(new int[][] {
{1,2,3},
{4,5,6},
{7,8,9},
});
maps.add(new int[][] {
{10,20,30},
{40,50,60},
});
int[][] map = maps.get(0);
System.out.println(map[0][0]);
}
}
The output will print correctly 1 , showing that there is no null pointer exception.

writing byte[] to file giving corrupt file

I am getting byte[] in request parameter in servlet which I am fetching in string and then again converting it into byte[] :
String encodingScheme = "UTF-8";
request.setCharacterEncoding(encodingScheme);
String requestStr = request.getParameter("inputstream");
byte[] rawRequestMsg = requestStr.getBytes(encodingScheme);
Now this byte[] I am trying to write to a .docx file as this byte[] which I am using is byte[] representation of a docx file only. Code for writing this to file is like :
String uploadedFileLocation = fileLocation;
FileOutputStream fileOuputStream = new FileOutputStream("path till .docx file");
fileOuputStream.write(byteArray);
fileOuputStream.close();
The problem is the .docx file being created is corrupt and unable to open, but when I change it to .doc then I can open it but instead of seeing the text content I see only the byte[] sequence there like below :
80, 75, 3, 4, 20, 0, 6, 0, 8, 0, 0, 0, 33, 0, -84, -122, 80, 87, -114, 1, 0, 0, -64, 5, 0, 0, 19, 0, 8, 2, 91, 67, 111, 110, 116, 101, 110, 116, 95, 84, 121, 112, 101, 115, 93, 46, 120, 109, 108, 32, -94, 4, 2, 40, -96, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Dont know how to write that correctly.
Need help.
Thanks,
Samir
Actually the code below used to work which is of a REST webservice
#
POST# Path("/binaryfileupload/{filename}")# Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response upload(byte[] input, #PathParam("filename") String filename) {
FileOutputStream fileOuputStream = new FileOutputStream(uploadedFileLocation);
fileOuputStream.write(input);
fileOuputStream.close();
}
Only change I made is from here this input which is byte[] I am sending to servlet and in servlet want to write file instead of writing in my webservice(which was working correctly).
You are not writing a .doc file. You're just writing a simple text file and naming it as .doc or .docx.
For it to work as a word document file, you need to use a library such as Apache POI to do it for you.
For more info about Apache POI, you can see here: https://poi.apache.org/
You can also refer this link How can I create a simple docx file with Apache POI?
I finally fixed it. I was making a small mistake. In the code
String requestStr = request.getParameter("inputstream");
byte[] rawRequestMsg = requestStr.getBytes(encodingScheme);
I am actually converting the String to byte even though its already in byte. thats why the value of requestStr is different than rawRequestMsg. Finally I used below code which simply takes the string into array and creates byte[] from it by individually separating each number :
String requestStr = request.getParameter("inputstream");
requestStr = requestStr.substring(1, requestStr.length() - 1);
String dataArray[] = requestStr.split(",");
byte[] rawRequestMsg = new byte[dataArray.length];
int count = 0;
for (String str: dataArray) {
str = str.trim();
rawRequestMsg[count++] = Byte.parseByte(str);
}
The trim function is used to remove whitespaces because its coming as 75, -84, 3 .... like this. And the substring is used to remove the [ from the begining and ] from the end.
Thanks everyone for helping me.
Hope this helps someone.

Non symmetric java compression

I have a data sample:
byte[] b = new byte[]{120, 1, -67, -107, -51, 106, 20, 81, 16, -123, 107, 18, -51, -60, 31, -30, 117, -4, -53, -60, -123, 25, 70, 71, 23, -111, 89, 12, 8, -83, 49, 4, -14, -93, -63, 73, 32, 89, -55, -112, -123, 10, -30, 66, 69, -110, 69, -64, -107, -77, 8, -72, 21, 23, -82, 5, -97, -64, 55, -48, -73, -16, 97, 4, -3, 14, -23, -110, 75, 59, 125, 39, 8, -10, -123, 51, -73, -86, -85, -6, 84, -99, -22, -18, 59, 53, 51, 27, 2, 95, 7, 24, 95, -36, 97, 95, 9, 102, -17, 46, -101, -51, -81, 109, -82, -101, -43, 44, -100, 54, -5, -56, -11, 9, -128, 105, -81, -128, -42, -25, -109, 102, -121, -109, 102, 63, 107, 102, 75, 32, 94, 79, -66, -43, 109, -15, -57, 9, 91, -79, 55, -74, 111, -49, -71, 103, -51, 54, 13, 58, -42, 121, 112, 22, 76, 3, -15, 5, -32, -21, 20, 70, 0, -94, 19, -58, -59, -59, 19, -128, -81, 51, 24, 1, -8, -3, 23, -80, -107, 35, -1, 38, -104, -51, 109, 54, 123, -12, -6, -67, 54, -69, 1, 60, -57, 109, 122, 27, -34, -29, -70, 122, -68, 10, 2, 80, 111, -102, -45, 29, 16, -64, 1, 40, -6, 15, -71, -26, -15, 45, -20, 103, 5, -1, 65, -28, 95, -57, 126, 90, -16, -69, -111, -33, -64, 46, -6, 47, -93, -72, -6, -39, 3, -9, -127, -6, 92, -52, -9, 37, -10, 89, -96, -72, -18, -9, 62, 93, 91, 29, 109, 110, 19, 30, -34, -30, -57, -11, 23, 103, -12, -31, -21, 119, -94, -57, -97, 81, 32, -9, 54, 120, 12, -60, -21, -21, 87, -66, 120, 93, -84, 73, 70, -117, -89, -47, -78, -7, 100, 94, 11, 21, 77, 107, 48, -21, 70, 50, -81, 78, -4, 72, 113, -102, 79, 111, 64, -99, -38, 1, -108, -51, 76, -3, -118, -83, 5, -92, -61, -25, -12, 63, 103, -42, -50, -21, -92, 102, -74, 64, 39, 61, -69, 6, -82, 36, 103, -47, 67, -35, 2, 95, 77, 27, -92, -8, -26, -120, 31, 77, 54, -51, -41, -96, -26, 28, -75, -37, -96, 108, 102, -102, -105, -66, -45, 94, -82, -93, -118, -103, 101, -44, -46, -5, -107, -46, -72, 74, 70, -97, 39, -39, -25, 61, 74, -27, -11, -19, -100, -83, -14, 5, 101, 32, -107, -41, 37, -34, 33, -73, 51, -122, -81, 67, -51, 46, -75, 51, 80, 54, -77, 14, -67, 79, -125, 126, -82, -93, -118, -103, 109, 80, 75, 103, 89, 74, -29, 14, 25, 3, -69, 4, 102, -110, 121, 3, -101, -78, 29, -72, -60, -103, -30, 91, 38, -98, -111, -101, -115, -31, -53, -88, -71, 76, -19, 13, 80, 54, 51, 61, 115, -83, 1, -112, -114, 127, -103, 25, -57, -112, 40, -2, -36, 91, -117, 108, -98, -57, 95, 103, 126, -109, -8, 39, -32, 103, -70, -50, -20, -94, -1, 54, -118, 43, 95, 126, -103, 6, -113, 59, 79, 21, 26, -12, 31, 16, -9, 124, 119, -124, 31, 107, 80, 126, 74, -125, -57, -99, -89, 10, 13, -21, -123, -98, -73, 71, -8, -79, 6, -27, -89, 52, 120, -36, 121, -86, -48, -80, 91, -24, -7, -59, 8, 63, -42, -96, -4, -108, 6, -113, 59, -49, 113, 52, -52, -64, 121, 17, 104, 5, 32, -5, 55, -108, 74, -2, -44};
it's just a compressed EMF image. I try to decompress it by code:
InflaterInputStream iis = new InflaterInputStream(new ByteArrayInputStream(b));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[4096];
int length = 0;
while ((length = iis.read(buf)) > 0) {
baos.write(buf, 0, length);
}
and get a CORRECT answer
[1, 0, 0, 0, -128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 118, 0, 0, 0, -93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 16, 0, 0, 127, 22, 0, 0, 32, 69, 77, 70, 0, 0, 1, 0, 16, 10, 0, 0, -110, 0, 0, 0, 2, 0, 0, 0, 10, 0, 0, 0, 108, 0, 0, 0, 0, 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, 0, 47, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 18, 0, 0, 0, 47, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 18, 0, 0, 0, 107, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 9, 0, 0, 0, 113, 0, 0, 0, 61, 0, 0, 0, 8, 0, 0, 0, 60, 0, 0, 0, 8, 0, 0, 0, 62, 0, 0, 0, 24, 0, 0, 0, 9, 0, 0, 0, 47, 0, 0, 0, 118, 0, 0, 0, -93, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 39, 0, 0, 0, 24, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -112, -79, -63, 0, 0, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 8, 0, 0, -128, 59, 0, 0, 0, 8, 0, 0, 0, 27, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 45, 0, 0, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 25, 0, 45, 0, 33, 0, 39, 0, 33, 0, 32, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 33, 0, 24, 0, 25, 0, 18, 0, 16, 0, 18, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 7, 0, 18, 0, 0, 0, 24, 0, 0, 0, 32, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 0, 0, 39, 0, 7, 0, 45, 0, 16, 0, 45, 0, 61, 0, 0, 0, 8, 0, 0, 0, 60, 0, 0, 0, 8, 0, 0, 0, 62, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 33, 0, 0, 0, 45, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 39, 0, 0, 0, 24, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -112, -79, -63, 0, 0, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 8, 0, 0, -128, 59, 0, 0, 0, 8, 0, 0, 0, 27, 0, 0, 0, 16, 0, 0, 0, 35, 0, 0, 0, 37, 0, 0, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 44, 0, 37, 0, 51, 0, 31, 0, 51, 0, 23, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 51, 0, 16, 0, 44, 0, 10, 0, 35, 0, 10, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 26, 0, 10, 0, 18, 0, 16, 0, 18, 0, 23, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 18, 0, 31, 0, 26, 0, 37, 0, 35, 0, 37, 0, 61, 0, 0, 0, 8, 0, 0, 0, 60, 0, 0, 0, 8, 0, 0, 0, 62, 0, 0, 0, 24, 0, 0, 0, 18, 0, 0, 0, 10, 0, 0, 0, 51, 0, 0, 0, 37, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 39, 0, 0, 0, 24, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -112, -79, -63, 0, 0, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 8, 0, 0, -128, 59, 0, 0, 0, 8, 0, 0, 0, 27, 0, 0, 0, 16, 0, 0, 0, 57, 0, 0, 0, 40, 0, 0, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 68, 0, 40, 0, 76, 0, 33, 0, 76, 0, 24, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 76, 0, 15, 0, 68, 0, 8, 0, 57, 0, 8, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 47, 0, 8, 0, 38, 0, 15, 0, 38, 0, 24, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 38, 0, 33, 0, 47, 0, 40, 0, 57, 0, 40, 0, 61, 0, 0, 0, 8, 0, 0, 0, 60, 0, 0, 0, 8, 0, 0, 0, 62, 0, 0, 0, 24, 0, 0, 0, 38, 0, 0, 0, 8, 0, 0, 0, 76, 0, 0, 0, 40, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 39, 0, 0, 0, 24, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -112, -79, -63, 0, 0, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 8, 0, 0, -128, 59, 0, 0, 0, 8, 0, 0, 0, 27, 0, 0, 0, 16, 0, 0, 0, 73, 0, 0, 0, 27, 0, 0, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 82, 0, 27, 0, 90, 0, 21, 0, 90, 0, 14, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 90, 0, 6, 0, 82, 0, 0, 0, 73, 0, 0, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 64, 0, 0, 0, 57, 0, 6, 0, 57, 0, 14, 0, 88, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 0, 0, 57, 0, 21, 0, 64, 0, 27, 0, 73, 0, 27, 0, 61, 0, 0, 0, 8, 0, 0, 0, 60, 0, 0, 0, 8, 0, 0, 0, 62, 0, 0, 0, 24, 0, 0, 0, 57, 0, 0, 0, 0, 0, 0, 0, 90, 0, 0, 0, 27, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 39, 0, 0, 0,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0, 0, 0, 58, 0, 0, 0, -106, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 39, 0, 0, 0, 24, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 8, 0, 0, -128, 59, 0, 0, 0, 8, 0, 0, 0, 27, 0, 0, 0, 16, 0, 0, 0, 70, 0, 0, 0, -106, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 81, 0, 0, 0, -106, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 81, 0, 0, 0, 121, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 70, 0, 0, 0, 121, 0, 0, 0, 61, 0, 0, 0, 8, 0, 0, 0, 60, 0, 0, 0, 8, 0, 0, 0, 62, 0, 0, 0, 24, 0, 0, 0, 70, 0, 0, 0, 121, 0, 0, 0, 81, 0, 0, 0, -106, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 39, 0, 0, 0, 24, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 8, 0, 0, -128, 59, 0, 0, 0, 8, 0, 0, 0, 27, 0, 0, 0, 16, 0, 0, 0, 92, 0, 0, 0, -106, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 103, 0, 0, 0, -106, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 103, 0, 0, 0, 121, 0, 0, 0, 54, 0, 0, 0, 16, 0, 0, 0, 92, 0, 0, 0, 121, 0, 0, 0, 61, 0, 0, 0, 8, 0, 0, 0, 60, 0, 0, 0, 8, 0, 0, 0, 62, 0, 0, 0, 24, 0, 0, 0, 92, 0, 0, 0, 121, 0, 0, 0, 103, 0, 0, 0, -106, 0, 0, 0, 37, 0, 0, 0, 12, 0, 0, 0, 7, 0, 0, -128, 37, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, -128, 40, 0, 0, 0, 12, 0, 0, 0, 1, 0, 0, 0, 14, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 20, 0, 0, 0]
After that i'm try to compress it back by code:
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
//Deflater defalter = new Deflater(1);
DeflaterOutputStream dos = new DeflaterOutputStream(baos2);//deflater, false);
dos.write(baos.toByteArray(), 0 , baos.toByteArray().length);
dos.finish();
And get a result:
[120, -100, -67, 84, 77, 47, 3, 81, 20, 61, -29, -85, 45, 13, -29, 91, 89, -48, -108, -78, 32, -77, -112, 72, -22, -93, 105, -126, -46, 40, 9, 43, 105, 44, -112, -120, 5, 34, 44, 36, 86, -70, -112, -40, -118, -123, -75, -60, 47, -16, 15, -8, 23, 126, -116, -124, 51, -45, -5, -30, -103, -52, -68, -63, 98, 94, 114, -46, 119, 122, -49, -36, 123, -49, 25, 106, 1, -88, -29, -5, 92, 17, -49, 26, 95, -74, -127, -101, 1, 96, 108, 117, -77, 12, 88, -80, -37, -127, 7, 126, -33, 68, -16, -118, 83, -47, 61, -75, 2, -73, -51, -64, -121, 5, 20, 45, -4, 56, -5, -81, 9, 44, -66, -73, 96, 25, -25, -72, -60, 17, -97, 89, -59, 38, -54, 94, -83, -101, 72, 19, 73, -23, 103, 107, -49, -91, -124, 91, -126, -88, 122, -38, 87, -17, -16, -43, 123, 69, -29, -34, 39, -119, 33, -71, -69, 103, -29, -20, -50, -5, -100, -48, 52, -22, -50, -35, -22, 11, -78, -29, -120, -12, 76, 73, 78, 115, -62, -81, 2, -8, -70, -58, -73, -120, 67, 31, 95, -45, -8, 56, 113, -32, -29, -114, -58, 123, 2, -8, -119, -58, -35, 125, 46, -120, 37, -39, 115, 81, 62, -117, -30, 51, 37, -49, -85, 61, -107, -73, 4, -67, -87, 59, 79, 125, -54, -112, -47, -3, -53, -37, -97, 50, 114, 49, 67, -20, 18, 83, -38, 123, -7, -108, -61, 63, 23, 100, -88, -56, 114, 82, 22, 99, 70, 93, -106, -101, 100, -24, -38, 38, 76, -70, -124, -105, -116, -69, -75, -71, -97, -21, 46, -63, -39, 54, 17, -106, 25, 36, -25, -84, -8, -120, 35, -77, -100, -44, 77, -69, 79, 83, 49, -117, 81, 98, -48, -88, -101, 101, -57, 105, -2, -41, -28, 8, -109, 110, -104, -11, 70, -78, -26, 126, 61, -100, 57, -52, -39, 57, 34, 44, 51, 55, -81, 118, 111, 118, -61, 71, 28, -103, 21, 100, 103, -45, -18, 43, -84, 84, -7, 38, -85, -100, 100, -46, 85, -47, 69, 109, -110, 61, -109, 70, -99, -61, 122, -98, -38, 124, 68, -65, 60, 103, 58, -84, 22, -120, -80, -52, -14, -62, -85, -46, 39, -114, -52, 42, 114, 55, -19, -66, 67, 69, 13, -3, 68, -89, 81, 87, 67, 27, -75, -115, -98, 38, 93, -55, 123, 87, 109, -124, -71, 95, -127, 51, 75, -100, 93, 33, -62, 50, 43, -56, 115, 53, -15, -15, -97, -52, 56, -18, 79, -103, 101, -120, 71, -4, -4, -115, -10, -13, 107, -115, 103, -124, -121, 121, 80, 117, -43, 39, 14, 15, -114, 111, -25, -7, 0, -82, 123, 112, 34, 60, -88, -70, -22, 19, -121, -121, -78, 111, -25, -19, 0, -82, 123, 40, 71, 120, 80, 117, -43, 39, 14, 15, 123, -66, -99, -113, 3, -72, -18, 97, 47, -62, -125, -86, -85, 62, -65, -15, -48, 73, -12, -55, -2, -74, -36, -65, 0, -108, 74, -2, -44]
the more similar result was achieved when i uncomment deflater initialization and using in DeflateOutputStream constructor.
As for me it's very strange behaviour or i don't use inflate/deflate mechanism properly.
Any idea?
Lossless compressors, to be called such, assure that compression followed by decompression produces exactly the same thing as what you started with.
On the other hand, there is no assurance nor any need to assure that decompression followed by compression should always produce the same result. Compressors can comply with the compressed data format, but produce very different results on the same input data depending the algorithm used and parameters of the algorithm that are chosen. Compressors often have different compression "levels" that allow the user to spend more or less CPU compressing better or worse, depending on the application. So you will get different output with different settings.

Categories