Revize e608f492
Přidáno uživatelem Michal Horký před asi 4 roky(ů)
project/Deserializer/src/io/FileWorker.java | ||
---|---|---|
106 | 106 |
} |
107 | 107 |
} |
108 | 108 |
|
109 |
public static PrintStream createRedirectStream() throws FileNotFoundException { |
|
110 |
return new PrintStream(new File("jdeserialize_log.txt"));
|
|
109 |
public static PrintStream createRedirectStream(boolean error) throws FileNotFoundException {
|
|
110 |
return new PrintStream(new File(error ? "jdeserialize_err.txt" : "jdeserialize_out.txt"));
|
|
111 | 111 |
} |
112 | 112 |
|
113 | 113 |
public static byte[] loadFileContent(File file) throws IOException { |
... | ... | |
118 | 118 |
return buffer; |
119 | 119 |
} |
120 | 120 |
|
121 |
public static byte[] unzipFile(byte content[]) throws IOException {
|
|
121 |
public static byte[] extractFileContent(byte rawContent[]) throws IOException {
|
|
122 | 122 |
byte buffer[]; |
123 | 123 |
|
124 | 124 |
IZipReader input; |
125 | 125 |
try { |
126 |
input = new ZipInStream(new ByteArrayInputStream(content));
|
|
126 |
input = new ZipInStream(new ByteArrayInputStream(rawContent));
|
|
127 | 127 |
} catch (NoSuchElementException e) { |
128 | 128 |
System.out.println("Note: the file may be a special type of ZIP archive."); |
129 |
input = new InflaterInStream(new ByteArrayInputStream(content));
|
|
129 |
input = new InflaterInStream(new ByteArrayInputStream(rawContent));
|
|
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
try { |
... | ... | |
148 | 148 |
System.out.println(String.format("The file is a%s ZIP archive...", input.getClass() == InflaterInStream.class ? " special" : "")); |
149 | 149 |
} catch (Exception e) { |
150 | 150 |
System.out.println("The file is not a ZIP archive..."); |
151 |
buffer = content;
|
|
151 |
buffer = rawContent;
|
|
152 | 152 |
} finally { |
153 | 153 |
input.close(); |
154 | 154 |
} |
Také k dispozici: Unified diff
re #7967
Zobrazení obsahu i u prázdného souboru. V případě nenačtení dat ze souboru, DB - vyskakovací okno s chybou. Úprava pro logovací soubory (rozdělení na out a err).