9 |
9 |
import java.io.IOException;
|
10 |
10 |
import java.io.ObjectInputStream;
|
11 |
11 |
import java.util.zip.ZipEntry;
|
12 |
|
import java.util.zip.ZipInputStream;
|
|
12 |
import java.util.zip.ZipFile;
|
13 |
13 |
|
14 |
14 |
import org.json.simple.JSONObject;
|
15 |
15 |
|
... | ... | |
60 |
60 |
Deserializer d = (Deserializer) ois.readObject();
|
61 |
61 |
System.out.println("Klasicka deserializace probehla v poradku.");
|
62 |
62 |
ois.close();
|
|
63 |
return true;
|
63 |
64 |
|
64 |
65 |
} catch (IOException e) {
|
65 |
66 |
|
... | ... | |
67 |
68 |
System.out.println("Chyba pri otevirani (uzavirani) streamu pri pokusu o klasickou deserializaci.");
|
68 |
69 |
e.printStackTrace();
|
69 |
70 |
|
70 |
|
return false;
|
71 |
|
|
72 |
71 |
} catch (Exception e) {
|
73 |
72 |
|
74 |
73 |
// Others: ClassNotFoundException, ClassCastException, ...
|
75 |
74 |
// Usually due to problems with classical deserialization.
|
76 |
|
return false;
|
77 |
75 |
|
78 |
76 |
}
|
79 |
|
return true;
|
|
77 |
return false;
|
80 |
78 |
}
|
81 |
79 |
|
82 |
80 |
private byte[] readByteArray() {
|
... | ... | |
90 |
88 |
* 50 4B 07 08 (spanned archive)
|
91 |
89 |
* Source: https://en.wikipedia.org/wiki/List_of_file_signatures
|
92 |
90 |
*/
|
93 |
|
ZipInputStream zipInputStream = null;
|
|
91 |
ZipFile zipFile = null;
|
94 |
92 |
ZipEntry entry = null;
|
95 |
93 |
try {
|
96 |
|
zipInputStream = new ZipInputStream(new FileInputStream(input));
|
97 |
|
entry = zipInputStream.getNextEntry();
|
98 |
|
System.out.println("Velikost ZIP dat je " + entry.getSize() + "B.");
|
|
94 |
zipFile = new ZipFile(input);
|
|
95 |
entry = (ZipEntry) zipFile.entries().nextElement();
|
|
96 |
System.out.println("Velikost ZIP dat je " + entry.getSize() + "B.");
|
99 |
97 |
} catch (Exception e) {
|
100 |
98 |
System.out.println("Soubor neni zazipovany...");
|
101 |
99 |
}
|
102 |
100 |
|
103 |
101 |
try {
|
104 |
102 |
if (entry != null) {
|
105 |
|
//array = new byte[(int) entry.getSize()];
|
106 |
|
array = entry.getExtra();
|
107 |
|
System.out.println(array.length);
|
108 |
|
//zipInputStream.read(array);
|
109 |
|
zipInputStream.close();
|
|
103 |
array = new byte[(int) entry.getSize()];
|
|
104 |
zipFile.getInputStream(entry).read(array);
|
110 |
105 |
} else {
|
111 |
106 |
array = new byte[(int) input.length()];
|
112 |
107 |
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(input));
|
#7794
U testovacích souborů od zákazníka potřeba jiného načítání - opraveno.