List of usage examples for org.apache.commons.io.output NullOutputStream nullOutputStream
public static OutputStream nullOutputStream()
From source file:org.talend.dataprep.api.preparation.PreparationUtilsTest.java
@Test public void prettyPrint() throws Exception { // given//from w w w .j a v a 2 s . co m final String version = versionService.version().getVersionId(); final List<Action> actions = getSimpleAction("uppercase", "column_name", "lastname"); final PreparationActions newContent = new PreparationActions(actions, version); final Step step = new Step(rootStep, newContent, version); final Preparation preparation = new Preparation("#15325878", "1234", step.id(), version); repository.add(newContent); repository.add(step); repository.add(preparation); // when PreparationUtils.prettyPrint(repository, preparation, new NullOutputStream()); // Basic walk through code, no assert. }
From source file:org.talend.dataprep.cache.noop.NoOpContentCache.java
/** * @see ContentCache#put(ContentCacheKey, TimeToLive) */// ww w . j av a 2s . c om @Override public OutputStream put(ContentCacheKey key, TimeToLive timeToLive) { return new NullOutputStream(); }
From source file:org.talend.dataprep.transformation.service.TransformationService.java
/** * Add the following preparation in cache. * * @param preparation the preparation to cache. * @param stepId the preparation step id. *///from w w w . jav a 2 s . c om private void addPreparationInCache(Preparation preparation, String stepId) { final ExportParameters exportParameters = new ExportParameters(); exportParameters.setPreparationId(preparation.getId()); exportParameters.setExportType("JSON"); exportParameters.setStepId(stepId); exportParameters.setDatasetId(preparation.getDataSetId()); final StreamingResponseBody streamingResponseBody = executeSampleExportStrategy(exportParameters); try { // the result is not important here as it will be cached ! streamingResponseBody.writeTo(new NullOutputStream()); } catch (IOException e) { throw new TDPException(UNEXPECTED_EXCEPTION, e); } }
From source file:org.vafer.jdeb.ChangesFileBuilder.java
public ChangesFile createChanges(BinaryPackageControlFile packageControlFile, File binaryPackage, ChangesProvider changesProvider) throws IOException, PackagingException { ChangesFile changesFile = new ChangesFile(); changesFile.setChanges(changesProvider.getChangesSets()); changesFile.initialize(packageControlFile); changesFile.set("Date", ChangesFile.DATE_FORMAT.format(new Date())); try {/*from w w w.ja v a 2 s .c om*/ // compute the checksums of the binary package InformationOutputStream md5output = new InformationOutputStream(new NullOutputStream(), MessageDigest.getInstance("MD5")); InformationOutputStream sha1output = new InformationOutputStream(md5output, MessageDigest.getInstance("SHA1")); InformationOutputStream sha256output = new InformationOutputStream(sha1output, MessageDigest.getInstance("SHA-256")); FileUtils.copyFile(binaryPackage, sha256output); // Checksums-Sha1: // 56ef4c6249dc3567fd2967f809c42d1f9b61adf7 45964 jdeb.deb changesFile.set("Checksums-Sha1", sha1output.getHexDigest() + " " + binaryPackage.length() + " " + binaryPackage.getName()); // Checksums-Sha256: // 38c6fa274eb9299a69b739bcbdbd05c7ffd1d8d6472f4245ed732a25c0e5d616 45964 jdeb.deb changesFile.set("Checksums-Sha256", sha256output.getHexDigest() + " " + binaryPackage.length() + " " + binaryPackage.getName()); StringBuilder files = new StringBuilder(md5output.getHexDigest()); files.append(' ').append(binaryPackage.length()); files.append(' ').append(packageControlFile.get("Section")); files.append(' ').append(packageControlFile.get("Priority")); files.append(' ').append(binaryPackage.getName()); changesFile.set("Files", files.toString()); } catch (NoSuchAlgorithmException e) { throw new PackagingException("Unable to compute the checksums for " + binaryPackage, e); } if (!changesFile.isValid()) { throw new PackagingException("Changes file fields are invalid " + changesFile.invalidFields() + ". The following fields are mandatory: " + changesFile.getMandatoryFields() + ". Please check your pom.xml/build.xml and your control file."); } return changesFile; }
From source file:org.vafer.jdependency.utils.DependencyUtils.java
public static Set<String> getDependenciesOfJar(final InputStream pInputStream) throws IOException { final JarInputStream inputStream = new JarInputStream(pInputStream); final NullOutputStream nullStream = new NullOutputStream(); final Set<String> dependencies = new HashSet<String>(); try {/*from w w w . j av a 2 s . com*/ while (true) { final JarEntry entry = inputStream.getNextJarEntry(); if (entry == null) { break; } if (entry.isDirectory()) { // ignore directory entries IOUtils.copy(inputStream, nullStream); continue; } final String name = entry.getName(); if (name.endsWith(".class")) { final DependenciesClassAdapter v = new DependenciesClassAdapter(); new ClassReader(inputStream).accept(v, 0); dependencies.addAll(v.getDependencies()); } else { IOUtils.copy(inputStream, nullStream); } } } finally { inputStream.close(); } return dependencies; }
From source file:org.webcat.core.git.PrettyDiffFormatter.java
public PrettyDiffFormatter() { super(new NullOutputStream()); prettyDiffs = new NSMutableDictionary<String, PrettyDiffResult>(); }
From source file:org.wso2.carbon.dataservices.core.boxcarring.RequestBox.java
/** * This is called when a boxcarring session is over, * and the stored requests will be executed, * the result of the last operation is returned. *///from w ww.j a va 2 s. c o m public synchronized OMElement execute() throws DataServiceFault { OMElement result; List<DataServiceRequest> reqList = this.getRequests(); int n = reqList.size(); OMElement resultElement = null; for (int i = 0; i < n; i++) { result = reqList.get(i).dispatch(); if (result != null) { try { /* if it's the last request, return the result, * getXMLStreamReader() method will execute the actual request */ if (i == (n - 1)) { resultElement = DBUtils.cloneAndReturnBuiltElement(result); return DBUtils.wrapBoxCarringResponse(resultElement); } else { /* process the result of the request, no need to cache the data */ result.serializeAndConsume(new NullOutputStream()); } } catch (XMLStreamException e) { throw new DataServiceFault(e, "Error in request box result serializing"); } } else { if (i == (n - 1)) { return DBUtils.wrapBoxCarringResponse(resultElement); } } } return null; }
From source file:org.wso2.carbon.dataservices.core.engine.DSOMDataSource.java
/** * This method is called when the current request is a in-only operations, * so a result is not expected./*from w ww .ja v a 2 s .c o m*/ */ public void executeInOnly() throws XMLStreamException { /* in case there is a result, write it to /dev/null */ XMLStreamWriter xmlWriter = DBUtils.getXMLOutputFactory().createXMLStreamWriter(new NullOutputStream()); this.serialize(xmlWriter); }
From source file:org.xwiki.formula.internal.NativeFormulaRenderer.java
/** * Execute a system command./* ww w.j ava 2 s . c o m*/ * * @param commandLine the command and its arguments * @param cwd the directory to use as the current working directory for the executed process * @return {@code true} if the command succeeded (return code 0), {@code false} otherwise * @throws IOException if the process failed to start */ private boolean executeCommand(String[] commandLine, File cwd) throws IOException { List<String> commandList = new Vector<String>(commandLine.length); Collections.addAll(commandList, commandLine); ProcessBuilder processBuilder = new ProcessBuilder(commandList); processBuilder.directory(cwd); Process process = processBuilder.start(); IOUtils.copy(process.getInputStream(), new NullOutputStream()); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } if (process.exitValue() != 0) { LOGGER.debug("Error generating image: " + IOUtils.toString(process.getErrorStream())); } return process.exitValue() == 0; }
From source file:org.xwiki.formula.internal.SnuggleTexFormulaRenderer.java
/** * {@inheritDoc}//from w w w.j a v a2 s. c o m */ @Override protected ImageData renderImage(String formula, boolean inline, FormulaRenderer.FontSize size, FormulaRenderer.Type type) throws IllegalArgumentException, IOException { SnuggleSession session = this.engine.createSession(); SnuggleInput input = new SnuggleInput(wrapFormula(formula, inline)); session.parseInput(input); ByteArrayOutputStream output = new ByteArrayOutputStream(); CustomMathMLImageSavingCallback callback = new CustomMathMLImageSavingCallback(output, size.getSize()); WebPageOutputOptions options = JEuclidUtilities.createWebPageOptions(false, callback); session.writeWebPage(options, new NullOutputStream()); return new ImageData(output.toByteArray(), type); }