org.apache.commons.io.output.CloseShieldOutputStream Java Examples
The following examples show how to use
org.apache.commons.io.output.CloseShieldOutputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CasDumpWriter.java From uima-uimafit with Apache License 2.0 | 6 votes |
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); try { if (out == null) { if ("-".equals(outputFile.getName())) { out = new PrintWriter(new CloseShieldOutputStream(System.out)); } else { if (outputFile.getParentFile() != null) { outputFile.getParentFile().mkdirs(); } out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")); } } } catch (IOException e) { throw new ResourceInitializationException(e); } cookedTypePatterns = compilePatterns(typePatterns); cookedFeaturePatterns = compilePatterns(featurePatterns); }
Example #2
Source File: CNDSerializer.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ public void writeContent(OutputStream out) throws IOException, RepositoryException { try (Writer w = new OutputStreamWriter(new CloseShieldOutputStream(out), "utf-8")) { for (String prefix: aggregate.getNamespacePrefixes()) { w.write("<'"); w.write(prefix); w.write("'='"); w.write(escape(aggregate.getNamespaceURI(prefix))); w.write("'>\n"); } w.write("\n"); writeNodeTypeDef(w, aggregate.getNode()); } out.flush(); }
Example #3
Source File: ForkingGradleHandle.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public GradleHandle start() { if (execHandle != null) { throw new IllegalStateException("you have already called start() on this handle"); } AbstractExecHandleBuilder execBuilder = execHandleFactory.create(); execBuilder.setStandardOutput(new CloseShieldOutputStream(new TeeOutputStream(System.out, standardOutput))); execBuilder.setErrorOutput(new CloseShieldOutputStream(new TeeOutputStream(System.err, errorOutput))); execHandle = execBuilder.build(); execHandle.start(); return this; }
Example #4
Source File: ForkingGradleHandle.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public GradleHandle start() { if (execHandle != null) { throw new IllegalStateException("you have already called start() on this handle"); } AbstractExecHandleBuilder execBuilder = execHandleFactory.create(); execBuilder.setStandardOutput(new CloseShieldOutputStream(new TeeOutputStream(System.out, standardOutput))); execBuilder.setErrorOutput(new CloseShieldOutputStream(new TeeOutputStream(System.err, errorOutput))); execHandle = execBuilder.build(); execHandle.start(); return this; }
Example #5
Source File: ForkingGradleHandle.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public GradleHandle start() { if (execHandle != null) { throw new IllegalStateException("you have already called start() on this handle"); } AbstractExecHandleBuilder execBuilder = execHandleFactory.create(); execBuilder.setStandardOutput(new CloseShieldOutputStream(new TeeOutputStream(System.out, standardOutput))); execBuilder.setErrorOutput(new CloseShieldOutputStream(new TeeOutputStream(System.err, errorOutput))); execHandle = execBuilder.build(); execHandle.start(); return this; }
Example #6
Source File: DumpReportTask.java From extract with MIT License | 5 votes |
@Override public Void call() throws Exception { final Optional<ExtractionStatus> result = options.get("reportStatus").value(ExtractionStatus::parse); try (final OutputStream output = new BufferedOutputStream(new CloseShieldOutputStream(System.out)); final ReportMap reportMap = new ReportMapFactory(options).createShared()) { monitor.hintRemaining(reportMap.size()); dump(reportMap, output, result.orElse(null)); } return null; }
Example #7
Source File: DumpQueueTask.java From extract with MIT License | 5 votes |
@Override public Void call() throws Exception { try (final OutputStream output = new BufferedOutputStream(new CloseShieldOutputStream(System.out)); final DocumentQueue queue = new DocumentQueueFactory(options).createShared()) { monitor.hintRemaining(queue.size()); dump(queue, output); } return null; }
Example #8
Source File: LobFile.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 5 votes |
@Override /** * {@inheritDoc} */ public OutputStream writeBlobRecord(long claimedLen) throws IOException { finishRecord(); // finish any previous record. checkForNull(this.out); startRecordIndex(); this.header.getStartMark().write(out); LOG.debug("Starting new record; id=" + curEntryId + "; claimedLen=" + claimedLen); WritableUtils.writeVLong(out, curEntryId); WritableUtils.writeVLong(out, claimedLen); this.curClaimedLen = claimedLen; this.userCountingOutputStream = new CountingOutputStream( new CloseShieldOutputStream(out)); if (null == this.codec) { // No codec; pass thru the same OutputStream to the user. this.userOutputStream = this.userCountingOutputStream; } else { // Wrap our CountingOutputStream in a compressing OutputStream to // give to the user. this.compressor.reset(); this.userOutputStream = new CompressorStream( this.userCountingOutputStream, compressor); } return this.userOutputStream; }
Example #9
Source File: ForkingGradleHandle.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public GradleHandle start() { if (execHandle != null) { throw new IllegalStateException("you have already called start() on this handle"); } AbstractExecHandleBuilder execBuilder = execHandleFactory.create(); execBuilder.setStandardOutput(new CloseShieldOutputStream(new TeeOutputStream(System.out, standardOutput))); execBuilder.setErrorOutput(new CloseShieldOutputStream(new TeeOutputStream(System.err, errorOutput))); execHandle = execBuilder.build(); execHandle.start(); return this; }
Example #10
Source File: PointFileReaderWriter.java From triplea with GNU General Public License v3.0 | 4 votes |
private static void write(final String string, final OutputStream sink) throws IOException { try (Writer out = new OutputStreamWriter(new CloseShieldOutputStream(sink), StandardCharsets.UTF_8)) { out.write(string); } }
Example #11
Source File: SafeStreams.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemOut() { return new CloseShieldOutputStream(System.out); }
Example #12
Source File: SafeStreams.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemErr() { return new CloseShieldOutputStream(System.err); }
Example #13
Source File: SafeStreams.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemErr() { return new CloseShieldOutputStream(System.err); }
Example #14
Source File: SafeStreams.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemOut() { return new CloseShieldOutputStream(System.out); }
Example #15
Source File: SafeStreams.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemErr() { return new CloseShieldOutputStream(System.err); }
Example #16
Source File: SafeStreams.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemOut() { return new CloseShieldOutputStream(System.out); }
Example #17
Source File: SafeStreams.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemOut() { return new CloseShieldOutputStream(System.out); }
Example #18
Source File: ModelSerializer.java From deeplearning4j with Apache License 2.0 | 4 votes |
/** * Write a model to an output stream * @param model the model to save * @param stream the output stream to write to * @param saveUpdater whether to save the updater for the model or not * @param dataNormalization the normalizer ot save (may be null) * @throws IOException */ public static void writeModel(@NonNull Model model, @NonNull OutputStream stream, boolean saveUpdater,DataNormalization dataNormalization) throws IOException { ZipOutputStream zipfile = new ZipOutputStream(new CloseShieldOutputStream(stream)); // Save configuration as JSON String json = ""; if (model instanceof MultiLayerNetwork) { json = ((MultiLayerNetwork) model).getLayerWiseConfigurations().toJson(); } else if (model instanceof ComputationGraph) { json = ((ComputationGraph) model).getConfiguration().toJson(); } ZipEntry config = new ZipEntry(CONFIGURATION_JSON); zipfile.putNextEntry(config); zipfile.write(json.getBytes()); // Save parameters as binary ZipEntry coefficients = new ZipEntry(COEFFICIENTS_BIN); zipfile.putNextEntry(coefficients); DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(zipfile)); INDArray params = model.params(); if(params != null) { try { Nd4j.write(model.params(), dos); } finally { dos.flush(); } } else { ZipEntry noParamsMarker = new ZipEntry(NO_PARAMS_MARKER); zipfile.putNextEntry(noParamsMarker); } if (saveUpdater) { INDArray updaterState = null; if (model instanceof MultiLayerNetwork) { updaterState = ((MultiLayerNetwork) model).getUpdater().getStateViewArray(); } else if (model instanceof ComputationGraph) { updaterState = ((ComputationGraph) model).getUpdater().getStateViewArray(); } if (updaterState != null && updaterState.length() > 0) { ZipEntry updater = new ZipEntry(UPDATER_BIN); zipfile.putNextEntry(updater); try { Nd4j.write(updaterState, dos); } finally { dos.flush(); } } } if(dataNormalization != null) { // now, add our normalizer as additional entry ZipEntry nEntry = new ZipEntry(NORMALIZER_BIN); zipfile.putNextEntry(nEntry); NormalizerSerializer.getDefault().write(dataNormalization, zipfile); } dos.close(); zipfile.close(); }
Example #19
Source File: WordVectorSerializer.java From deeplearning4j with Apache License 2.0 | 4 votes |
/** * This method saves specified SequenceVectors model to target OutputStream * * @param vectors SequenceVectors model * @param stream Target output stream * @param <T> */ public static <T extends SequenceElement> void writeSequenceVectors(@NonNull SequenceVectors<T> vectors, @NonNull OutputStream stream) throws IOException { InMemoryLookupTable<VocabWord> lookupTable = (InMemoryLookupTable<VocabWord>) vectors.getLookupTable(); AbstractCache<T> vocabCache = (AbstractCache<T>) vectors.getVocab(); try (ZipOutputStream zipfile = new ZipOutputStream(new BufferedOutputStream(new CloseShieldOutputStream(stream))); DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(zipfile))) { ZipEntry config = new ZipEntry(CONFIG_ENTRY); zipfile.putNextEntry(config); VectorsConfiguration configuration = vectors.getConfiguration(); String json = configuration.toJson().trim(); zipfile.write(json.getBytes("UTF-8")); ZipEntry vocab = new ZipEntry(VOCAB_ENTRY); zipfile.putNextEntry(vocab); zipfile.write(vocabCache.toJson().getBytes("UTF-8")); INDArray syn0Data = lookupTable.getSyn0(); ZipEntry syn0 = new ZipEntry(SYN0_ENTRY); zipfile.putNextEntry(syn0); Nd4j.write(syn0Data, dos); dos.flush(); INDArray syn1Data = lookupTable.getSyn1(); if (syn1Data != null) { ZipEntry syn1 = new ZipEntry(SYN1_ENTRY); zipfile.putNextEntry(syn1); Nd4j.write(syn1Data, dos); dos.flush(); } INDArray syn1NegData = lookupTable.getSyn1Neg(); if (syn1NegData != null) { ZipEntry syn1neg = new ZipEntry(SYN1_NEG_ENTRY); zipfile.putNextEntry(syn1neg); Nd4j.write(syn1NegData, dos); dos.flush(); } } }
Example #20
Source File: SafeStreams.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public static OutputStream systemErr() { return new CloseShieldOutputStream(System.err); }