當前位置: 首頁>>代碼示例>>Java>>正文


Java NullOutputStream類代碼示例

本文整理匯總了Java中org.apache.commons.io.output.NullOutputStream的典型用法代碼示例。如果您正苦於以下問題:Java NullOutputStream類的具體用法?Java NullOutputStream怎麽用?Java NullOutputStream使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NullOutputStream類屬於org.apache.commons.io.output包,在下文中一共展示了NullOutputStream類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fileTransferRequest

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
@Override
public void fileTransferRequest(FileTransferRequest request) {
    final IncomingFileTransfer transfer = request.accept();

    Thread transferThread = new Thread(new Runnable() {
        public void run() {
            try {
                OutputStream os = new NullOutputStream();
                InputStream is = transfer.recieveFile();
                log.debug("Reading from stream: " + is.available());
                IOUtils.copy(is, os);
                log.debug("Left in stream: " + is.available());
            } catch (Exception e) {
                log.error("Failed incoming file transfer", e);
            }
        }
    });
    transferThread.start();
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:20,代碼來源:SendFileXEP0096.java

示例2: testDownloadGzip

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
@Test
public void testDownloadGzip() throws Exception {
    final Host host = new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com", new Credentials(
            System.getProperties().getProperty("rackspace.key"), System.getProperties().getProperty("rackspace.secret")
    ));
    final SwiftSession session = new SwiftSession(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    status.setLength(182L);
    final Path container = new Path(".ACCESS_LOGS", EnumSet.of(Path.Type.directory, Path.Type.volume));
    container.attributes().setRegion("DFW");
    final SwiftRegionService regionService = new SwiftRegionService(session);
    final InputStream in = new SwiftReadFeature(session, regionService).read(new Path(container,
            "/cdn.cyberduck.ch/2015/03/01/10/3b1d6998c430d58dace0c16e58aaf925.log.gz",
            EnumSet.of(Path.Type.file)), status, new DisabledConnectionCallback());
    assertNotNull(in);
    new StreamCopier(status, status).transfer(in, new NullOutputStream());
    assertEquals(182L, status.getOffset());
    assertEquals(182L, status.getLength());
    in.close();
    session.close();
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:24,代碼來源:SwiftReadFeatureTest.java

示例3: testDownloadGzip

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
@Test
public void testDownloadGzip() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
    ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final int length = 1457;
    final byte[] content = RandomUtils.nextBytes(length);
    final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path file = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final TransferStatus status = new TransferStatus().length(content.length);
    status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), status));
    final OutputStream out = new S3WriteFeature(session).write(file, status, new DisabledConnectionCallback());
    new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out);
    out.close();
    final InputStream in = new S3ReadFeature(session).read(file, status, new DisabledConnectionCallback());
    assertNotNull(in);
    new StreamCopier(status, status).transfer(in, new NullOutputStream());
    assertEquals(content.length, status.getOffset());
    assertEquals(content.length, status.getLength());
    in.close();
    new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:27,代碼來源:S3ReadFeatureTest.java

示例4: shouldRejectMissingEnv

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
@Test
public void shouldRejectMissingEnv() {
    Map<String, String> requiredEnv = new HashMap<>();

    requiredEnv.put("FN_PATH", "/route");
    requiredEnv.put("FN_METHOD", "GET");
    requiredEnv.put("FN_APP_NAME", "app_name");
    requiredEnv.put("FN_REQUEST_URL", "http://test.com/fn/tryInvoke");

    for (String key : requiredEnv.keySet()) {
        Map<String, String> newEnv = new HashMap<>(requiredEnv);
        newEnv.remove(key);

        DefaultEventCodec codec = new DefaultEventCodec(newEnv, asStream("input"), new NullOutputStream());

        try{
            codec.readEvent();
            fail("Should have rejected missing env "+ key);
        }catch(FunctionInputHandlingException e){
            assertThat(e).hasMessageContaining("Required environment variable " + key+ " is not set - are you running a function outside of fn run?");
        }
    }

}
 
開發者ID:fnproject,項目名稱:fdk-java,代碼行數:25,代碼來源:DefaultEventCodecTest.java

示例5: MediniQVTFamiliesToPersonsConfig

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
public MediniQVTFamiliesToPersonsConfig() {
	super(new FamiliesComparator(), new PersonsComparator());
	
	logger = new OutputStreamLog(new PrintStream(new NullOutputStream())); 
	// logger = new OutputStreamLog(System.err); 
	
	processorImpl = new EMFQvtProcessorImpl(this.logger);
	processorImpl.setProperty(QVTProcessorConsts.PROP_DEBUG, "true");
	basePath = "./src/org/benchmarx/examples/familiestopersons/implementations/medini/base/";
	
	// Tell the QVT engine, which transformation to execute
	transformation = "families2personsconfig";

	// Tell the QVT engine a directory to work in - e.g. to store the trace (meta)models
	File tracesFile = new File(basePath + "traces/trace.trafo");
	tracesFile.delete();
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:18,代碼來源:MediniQVTFamiliesToPersonsConfig.java

示例6: launch

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
/**
 * launch the transformation in the QVT execution engine
 * 
 * @param direction : the desired execution direction
 */
public void launch(String direction) {
	PrintStream ps = System.out;
	PrintStream ps_err = System.err;
	
	// Load the QVT relations
	try {
		System.setOut(new PrintStream(new NullOutputStream()));
		System.setErr(new PrintStream(new NullOutputStream()));

		qvtRuleSet = new FileReader(basePath + RULESET);
		this.transform(qvtRuleSet, transformation, direction);
	} catch (FileNotFoundException fileNotFoundException) {
		fileNotFoundException.printStackTrace();
		return;
	} catch (Throwable throwable) {
		throwable.printStackTrace();
	} finally {		
		System.setOut(ps);
		System.setErr(ps_err);
	}
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:27,代碼來源:MediniQVTFamiliesToPersonsConfig.java

示例7: MediniQVTFamiliesToPersons

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
public MediniQVTFamiliesToPersons() {
	super(new FamiliesComparator(), new PersonsComparator());
	
	logger = new OutputStreamLog(new PrintStream(new NullOutputStream())); 
	// logger = new OutputStreamLog(System.err); 
	
	processorImpl = new EMFQvtProcessorImpl(this.logger);
	processorImpl.setProperty(QVTProcessorConsts.PROP_DEBUG, "true");
	basePath = "./src/org/benchmarx/examples/familiestopersons/implementations/medini/base/";
	
	// Tell the QVT engine, which transformation to execute
	transformation = "families2persons";

	// Tell the QVT engine a directory to work in - e.g. to store the trace (meta)models
	File tracesFile = new File(basePath + "traces/trace.trafo");
	tracesFile.delete();
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:18,代碼來源:MediniQVTFamiliesToPersons.java

示例8: launch

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
/**
 * launch the transformation in the QVT execution engine
 * 
 * @param direction : the desired execution direction
 */
public void launch(String direction) {
	PrintStream ps = System.out;
	PrintStream ps_err = System.err;
	
	// Load the QVT relations
	try {
		System.setOut(new PrintStream(new NullOutputStream()));
		System.setErr(new PrintStream(new NullOutputStream()));

		qvtRuleSet = new FileReader(basePath + RULESET);
		this.transform(qvtRuleSet, transformation, direction);
	} catch (FileNotFoundException fileNotFoundException) {
		fileNotFoundException.printStackTrace();
		return;
	} catch (Throwable throwable) {
		throwable.printStackTrace();
		System.out.println(throwable.getMessage());
	} finally {		
		System.setOut(ps);
		System.setErr(ps_err);
	}
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:28,代碼來源:MediniQVTFamiliesToPersons.java

示例9: writeObject

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
/**
 * Custom serialization method.
 *
 * @param oos the object output stream
 * @throws IOException
 */
protected void writeObject(ObjectOutputStream oos) throws IOException {

  // figure out size of the written network
  CountingOutputStream cos = new CountingOutputStream(new NullOutputStream());
  if (replaceMissingFilter != null) {
    ModelSerializer.writeModel(model, cos, false);
  }
  modelSize = cos.getByteCount();

  // default serialization
  oos.defaultWriteObject();

  // actually write the network
  if (replaceMissingFilter != null) {
    ModelSerializer.writeModel(model, oos, false);
  }
}
 
開發者ID:Waikato,項目名稱:wekaDeeplearning4j,代碼行數:24,代碼來源:Dl4jMlpClassifier.java

示例10: testIdiomaticInvokationThrowsException

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
/**
 * Demonstrates idiomatic exception handling with try-with-resources
 *
 * @throws Exception if something exceptional happens
 */
@Test
public void testIdiomaticInvokationThrowsException() throws Exception {
    final InputStream mockBody = mock(InputStream.class);
    final IOException ioe = new IOException("Mocked IOE");
    when(mockBody.read(any(byte[].class))).thenThrow(ioe);

    final FcrepoClient client = mock(FcrepoClient.class);
    final GetBuilder getBuilder = mock(GetBuilder.class);

    when(client.get(any(URI.class))).thenReturn(getBuilder);
    when(getBuilder.perform()).thenReturn(new FcrepoResponse(null, 200, null, mockBody));

    try (FcrepoResponse res = client.get(URI.create("foo")).perform()) {
        ByteStreams.copy(res.getBody(), NullOutputStream.NULL_OUTPUT_STREAM);
        fail("Expected an IOException to be thrown.");
    } catch (IOException e) {
        assertSame(ioe, e);
    }

    verify(mockBody).close();
}
 
開發者ID:fcrepo4-exts,項目名稱:fcrepo-java-client,代碼行數:27,代碼來源:FcrepoResponseTest.java

示例11: workflowBundle

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
@Test
public void workflowBundle() throws Exception {
	ByteArrayOutputStream outStream = new ByteArrayOutputStream();
	// To test that seeAlso URIs are stored
	serializer.workflowDoc(new NullOutputStream(), workflowBundle.getMainWorkflow(), URI.create(HELLOWORLD_RDF));
	serializer.profileDoc(new NullOutputStream(), workflowBundle.getProfiles().getByName("tavernaWorkbench"), URI.create(TAVERNAWORKBENCH_RDF));
	serializer.profileDoc(new NullOutputStream(), workflowBundle.getProfiles().getByName("tavernaServer"), URI.create(TAVERNASERVER_RDF));

	serializer.workflowBundleDoc(outStream, URI.create("workflowBundle.rdf"));
	//System.out.write(outStream.toByteArray());
	Document doc = parseXml(outStream);
	Element root = doc.getRootElement();

	checkRoot(root);
	checkWorkflowBundleDocument(root);

}
 
開發者ID:apache,項目名稱:incubator-taverna-language,代碼行數:18,代碼來源:TestRDFXMLSerializer.java

示例12: prepareFileEntry

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
public void prepareFileEntry(RmpFileEntry entry) throws IOException, InterruptedException {
	EntryInfo info = new EntryInfo();
	info.name = entry.getFileName();
	info.extendsion = entry.getFileExtension();
	long pos = rmpOutputFile.getFilePointer();
	info.offset = pos;
	CountingOutputStream cout = new CountingOutputStream(new NullOutputStream());
	entry.writeFileContent(cout);
	info.length = cout.getBytesWritten();
	long newPos = pos + info.length;
	if ((info.length % 2) != 0)
		newPos++;
	if (newPos > MAX_FILE_SIZE)
		throwRmpTooLarge();
	rmpOutputFile.seek(newPos);
	entries.add(info);
	log.debug("Prepared data of entry " + entry + " bytes=" + info.length);
}
 
開發者ID:bh4017,項目名稱:mobac,代碼行數:19,代碼來源:RmpWriter.java

示例13: execute

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
/**
 * Execute a Drush command.
 */
protected boolean execute(ArgumentListBuilder args, TaskListener out) throws IOException, InterruptedException {
	ProcStarter starter = launcher.launch().pwd(workspace).cmds(args);
	if (out == null) {
		// Output stdout/stderr into listener.
		starter.stdout(listener);
	} else {
		// Output stdout into out.
		// Do not output stderr since this breaks the XML formatting on stdout.
		starter.stdout(out).stderr(NullOutputStream.NULL_OUTPUT_STREAM);
	}
	starter.join();
	return true;
}
 
開發者ID:jenkinsci,項目名稱:drupal-developer-plugin,代碼行數:17,代碼來源:DrushInvocation.java

示例14: getUnsafeResultElements

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
/**
 * Gets a map of unsafe result elements, ie. elements that cannot be saved
 * because serialization fails.
 *
 * @return
 */
public Map<ComponentJob, AnalyzerResult> getUnsafeResultElements() {
    if (_unsafeResultElements == null) {
        _unsafeResultElements = new LinkedHashMap<>();
        final Map<ComponentJob, AnalyzerResult> resultMap = _analysisResult.getResultMap();
        for (final Entry<ComponentJob, AnalyzerResult> entry : resultMap.entrySet()) {
            final AnalyzerResult analyzerResult = entry.getValue();
            try {
                SerializationUtils.serialize(analyzerResult, new NullOutputStream());
            } catch (final SerializationException e) {
                _unsafeResultElements.put(entry.getKey(), analyzerResult);
            }
        }
    }
    return _unsafeResultElements;
}
 
開發者ID:datacleaner,項目名稱:DataCleaner,代碼行數:22,代碼來源:AnalysisResultSaveHandler.java

示例15: prettyPrint

import org.apache.commons.io.output.NullOutputStream; //導入依賴的package包/類
@Test
public void prettyPrint() throws Exception {
    // given
    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(Step.ROOT_STEP.id(), newContent.id(), 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.
}
 
開發者ID:Talend,項目名稱:data-prep,代碼行數:19,代碼來源:PreparationUtilsTest.java


注:本文中的org.apache.commons.io.output.NullOutputStream類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。