/** Returns the input stream, decompressing if required. */ private InputStream readFile(String filePath) throws IOException { BufferedInputStream input = new BufferedInputStream(openFile(filePath), BUFFER_SIZE); input.mark(100); try { return new XZInputStream(input); } catch (IOException e) { input.reset(); } try { return new CompressorStreamFactory().createCompressorInputStream(input); } catch (CompressorException e) { input.reset(); } try { return new ArchiveStreamFactory().createArchiveInputStream(input); } catch (ArchiveException e) { input.reset(); } return input; }
countingStream = new CountingInputStream(inputStream); if (decompressConcatenated) { in = new XZInputStream(countingStream, memoryLimitInKb); } else { in = new SingleXZInputStream(countingStream, memoryLimitInKb);
break; case COMPRESSION_FORMAT_XZ_LZMA2: compressionIn = new XZInputStream(bufferedIn); break; case COMPRESSION_FORMAT_BZIP2:
static public XZInputStream createXZBufferedInputStream(InputStream in) { XZInputStream zin = null; try { zin = new XZInputStream(new BufferedInputStream(in)); } catch (IOException e) {e.printStackTrace();} return zin; }
static public XZInputStream createXZBufferedInputStream(InputStream in) { XZInputStream zin = null; try { zin = new XZInputStream(new BufferedInputStream(in)); } catch (IOException e) {e.printStackTrace();} return zin; }
private static InputStream wrapStream(InputStream baseStream, String filename) throws IOException { baseStream = new BufferedInputStream(baseStream); if (filename.endsWith(".xz")) { baseStream = new XZInputStream(baseStream); } else if (filename.endsWith(".gz")) { baseStream = new GZIPInputStream(baseStream); } return baseStream; }
static public XZInputStream createXZBufferedInputStream(String filename) { XZInputStream zin = null; try { zin = new XZInputStream(new BufferedInputStream(new FileInputStream(filename))); } catch (IOException e) {e.printStackTrace();} return zin; }
static public ObjectInputStream getObjectInputStream(String modelPath) { try { return new ObjectInputStream(new XZInputStream(new BufferedInputStream(IOUtils.getInputStreamsFromClasspath(modelPath)))); } catch (IOException e) {e.printStackTrace();} return null; } }
public void byteArrayToModels(byte[] bytes) throws Exception { ObjectInputStream oin = new ObjectInputStream(new XZInputStream(new BufferedInputStream(new ByteArrayInputStream(bytes)))); for (StringModel model : s_models) model.load(oin); oin.close(); }
static public XZInputStream createXZBufferedInputStream(String filename) { XZInputStream zin = null; try { zin = new XZInputStream(new BufferedInputStream(new FileInputStream(filename))); } catch (IOException e) {e.printStackTrace();} return zin; }
public void byteArrayToModels(byte[] bytes) throws Exception { ObjectInputStream oin = new ObjectInputStream(new XZInputStream(new BufferedInputStream(new ByteArrayInputStream(bytes)))); for (StringModel model : s_models) model.load(oin); oin.close(); }
static public ObjectInputStream getObjectInputStream(String modelPath) { try { return new ObjectInputStream(new XZInputStream(new BufferedInputStream(IOUtils.getInputStreamsFromClasspath(modelPath)))); } catch (IOException e) {e.printStackTrace();} return null; } }
public void loadWeightVectorFromByteArray(byte[] array) throws Exception { ObjectInputStream ois = new ObjectInputStream(new XZInputStream(new BufferedInputStream(new ByteArrayInputStream(array)))); setWeightVector((AbstractWeightVector)ois.readObject()); ois.close(); }
protected void initDecode(byte[] models) { try { ObjectInputStream ois = new ObjectInputStream(new XZInputStream(new BufferedInputStream(new ByteArrayInputStream(models)))); initDecode(ois); } catch (IOException e) {e.printStackTrace();} }
public void loadWeightVectorFromByteArray(byte[] array) throws Exception { ObjectInputStream ois = new ObjectInputStream(new XZInputStream(new BufferedInputStream(new ByteArrayInputStream(array)))); setWeightVector((AbstractWeightVector)ois.readObject()); ois.close(); }
public static void main(String[] args) throws Exception { String from = args[0]; String to = args[1]; try (FileInputStream fileStream = new FileInputStream(from); XZInputStream xzStream = new XZInputStream(fileStream, BasicArrayCache.getInstance())) { Files.copy(xzStream, Paths.get(to), StandardCopyOption.REPLACE_EXISTING); } } }
@Override public Optional<InputStream> getInputStream() { try { return optional(new XZInputStream(new BufferedInputStream(new FileInputStream(file)))); } catch (IOException e) { LOGGER.error("File cannot be found or opened", e); failedOnStreams.set(true); return emptyOptional(); } } }
@Override public Optional<InputStream> getInputStream() { try { return optional(new XZInputStream(new BufferedInputStream(new FileInputStream(file)))); } catch (IOException e) { LOGGER.error("File cannot be found or opened", e); failedOnStreams.set(true); return emptyOptional(); } } }
@Override public Optional<InputStream> getInputStream() { try { return optional(new XZInputStream(new BufferedInputStream(new FileInputStream(file)))); } catch (IOException e) { LOGGER.error("File cannot be found or opened", e); failedOnStreams.set(true); return emptyOptional(); } } }
@Override public Optional<InputStream> getInputStream() { if (buffer == null) { return emptyOptional(); } try { return optional(new XZInputStream(new ByteArrayInputStream(buffer))); } catch (IOException e) { LOGGER.error("Buffer cannot be opened", e); failedOnStreams.set(true); return emptyOptional(); } }