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


Java TeeOutputStream類代碼示例

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


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

示例1: getOutputStream

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
@Override
public ServletOutputStream getOutputStream() throws IOException {
    return new ServletOutputStream() {
        @Override
        public boolean isReady() {
            return false;
        }

        @Override
        public void setWriteListener(WriteListener writeListener) {

        }

        private TeeOutputStream tee = new TeeOutputStream(ResponseWrapper.super.getOutputStream(), bos);

        @Override
        public void write(int b) throws IOException {
            tee.write(b);
        }
    };
}
 
開發者ID:warlock-china,項目名稱:wisp,代碼行數:22,代碼來源:ResponseWrapper.java

示例2: getOutputStream

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
/**
 * Returns an OuputStream that writes to local webapp and to file inside <code>MCR.WCMS2.DataDir</code>.
 */
public static OutputStream getOutputStream(String path) throws IOException {
    String cleanPath = path.startsWith("/") ? path.substring(1) : path;
    File wcmsDataDir = getWCMSDataDir();
    File webappBaseDir = getWebAppBaseDir();
    File webappTarget = new File(webappBaseDir, cleanPath);
    if (!webappTarget.toPath().startsWith(webappBaseDir.toPath())) {
        throw new IOException(String.format(Locale.ROOT, "Cannot write %s outside the web application: %s",
            webappTarget, webappBaseDir));
    }
    File wcmsDataDirTarget = new File(wcmsDataDir, cleanPath);
    createDirectoryIfNeeded(webappTarget);
    createDirectoryIfNeeded(wcmsDataDirTarget);
    LOGGER.info(String.format(Locale.ROOT, "Writing content to %s and to %s.", webappTarget, wcmsDataDirTarget));
    return new TeeOutputStream(new FileOutputStream(wcmsDataDirTarget), new FileOutputStream(webappTarget));
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:19,代碼來源:MCRWebPagesSynchronizer.java

示例3: startPlatformLogging

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
private static void startPlatformLogging(Path fileName) {
	sysOut = System.out;
	sysErr = System.err;
	try {
		File file = null;
		file = fileName.toFile();
		file.getParentFile().mkdirs();
		file.createNewFile();
		FileOutputStream fos = new FileOutputStream(file);
		TeeOutputStream bothStream =new TeeOutputStream(System.out, fos);
		PrintStream ps = new PrintStream(bothStream);
		System.setOut(ps);
		System.setErr(ps);
	} catch(Exception e) {
		e.printStackTrace();
		throw new IllegalArgumentException("cannot redirect to output file");
	}
	System.out.println("StartTime: " + System.currentTimeMillis());
}
 
開發者ID:atlarge-research,項目名稱:graphalytics-platforms-powergraph,代碼行數:20,代碼來源:PowergraphPlatform.java

示例4: AbstractCppcheckCommand

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
public AbstractCppcheckCommand(IConsole console, String[] defaultArguments,
		long timeout, String binaryPath) {

	this.binaryPath = binaryPath;
	this.console = console;
	this.defaultArguments = defaultArguments;
	
	executor = new DefaultExecutor();

	// all modes of operation returns 0 when no error occured,
	executor.setExitValue(0);

	watchdog = new ExecuteWatchdog(timeout);
	executor.setWatchdog(watchdog);

	out = new ByteArrayOutputStream();
	err = new ByteArrayOutputStream();

	processStdOut = new LineFilterOutputStream(new TeeOutputStream(out,
			console.getConsoleOutputStream(false)), DEFAULT_CHARSET);
	processStdErr = new LineFilterOutputStream(new TeeOutputStream(err,
			console.getConsoleOutputStream(true)), DEFAULT_CHARSET);
	
}
 
開發者ID:kwin,項目名稱:cppcheclipse,代碼行數:25,代碼來源:AbstractCppcheckCommand.java

示例5: downloadDocker

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
private FilePath downloadDocker(DumbSlave slave, FilePath toolDir, String version) throws IOException, InterruptedException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    TeeOutputStream tee = new TeeOutputStream(baos, new PlainTextConsoleOutputStream(System.err));
    TaskListener l = new StreamTaskListener(tee);

    FilePath exe = toolDir.child(version+"/bin/docker");
    // Download for first time:
    assertEquals(exe.getRemote(), DockerTool.getExecutable(version, slave, l, null));
    assertTrue(exe.exists());
    assertThat(baos.toString(), containsString(Messages.DockerToolInstaller_downloading_docker_client_(version)));
    // Next time we do not need to download:
    baos.reset();
    assertEquals(exe.getRemote(), DockerTool.getExecutable(version, slave, l, null));
    assertTrue(exe.exists());
    assertThat(baos.toString(), not(containsString(Messages.DockerToolInstaller_downloading_docker_client_(version))));
    // Version check:
    baos.reset();
    assertEquals(0, slave.createLauncher(l).launch().cmds(exe.getRemote(), "version", "--format", "{{.Client.Version}}").quiet(true).stdout(tee).stderr(System.err).join());
    if (!version.equals("latest")) {
        assertEquals(version, baos.toString().trim());
    }
    return exe;
}
 
開發者ID:jenkinsci,項目名稱:docker-commons-plugin,代碼行數:24,代碼來源:DockerToolInstallerTest.java

示例6: getOutputStream

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
@Override
public ServletOutputStream getOutputStream() throws IOException {
    return new ServletOutputStream() {
        private TeeOutputStream tee = new TeeOutputStream(ResponseWrapper.super.getOutputStream(), bos);

        @Override
        public boolean isReady() {
            return true;
        }

        @Override
        public void setWriteListener(WriteListener writeListener) {
        }

        @Override
        public void write(int b) throws IOException {
            tee.write(b);
        }
    };
}
 
開發者ID:sofn,項目名稱:app-engine,代碼行數:21,代碼來源:ResponseWrapper.java

示例7: startPlatformLogging

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
public static void startPlatformLogging(Path fileName) {
	defaultSysOut = System.out;
	deafultSysErr = System.err;
	try {
		File file = fileName.toFile();
		file.getParentFile().mkdirs();
		file.createNewFile();
		FileOutputStream fos = new FileOutputStream(file);
		TeeOutputStream bothStream = new TeeOutputStream(System.out, fos);
		PrintStream ps = new PrintStream(bothStream);
		System.setOut(ps);
		System.setErr(ps);
	} catch (Exception e) {
		e.printStackTrace();
		LOG.error("Failed to redirect to log file %s", fileName);
		throw new GraphalyticsExecutionException("Failed to log the benchmark run. Benchmark run aborted.");
	}
}
 
開發者ID:ldbc,項目名稱:ldbc_graphalytics,代碼行數:19,代碼來源:__platform-name__Collector.java

示例8: getOutputStream

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
@Override
public ServletOutputStream getOutputStream() throws IOException {
    return new ServletOutputStream() {
        private TeeOutputStream tee = new TeeOutputStream(ResponseWrapper.super.getOutputStream(), bos);

        @Override
        public void write(int b) throws IOException {
            tee.write(b);
        }

        @Override
        public boolean isReady() {
            // Auto-generated method stub
            return false;
        }

        @Override
        public void setWriteListener(WriteListener listener) {
            // Auto-generated method stub
        }
    };
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:BikeMan,代碼行數:23,代碼來源:ResponseWrapper.java

示例9: setConsoleOutput

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
public void setConsoleOutput(File local_output, boolean quiet, boolean silent) throws Exception {
	//Setting all system outputs to write to local_output file
	FileOutputStream logfile = new FileOutputStream(local_output);
	System.setOut(new PrintStream(new TeeOutputStream(System.out, logfile)));
	System.setOut(new PrintStream(new TeeOutputStream(System.err, logfile)));
	
	//Setting all LOGs to write to local_output file
	Properties prop = new Properties();
	if (!quiet && !silent) {
		prop.setProperty("log4j.rootLogger", "INFO, console, WORKLOG");
		prop.setProperty("log4j.appender.console","org.apache.log4j.ConsoleAppender");
		prop.setProperty("log4j.appender.console.target", "System.err");
		prop.setProperty("log4j.appender.console.layout", "org.apache.log4j.PatternLayout");
		prop.setProperty("log4j.appender.console.layout.ConversionPattern", "%d [%p - %l] %m%n");
	}
	else {
		prop.setProperty("log4j.rootLogger", "INFO, WORKLOG");
	}
	prop.setProperty("log4j.appender.WORKLOG", "org.apache.log4j.FileAppender");
	prop.setProperty("log4j.appender.WORKLOG.File", local_output.toString());
	prop.setProperty("log4j.appender.WORKLOG.layout","org.apache.log4j.PatternLayout");
	prop.setProperty("log4j.appender.WORKLOG.layout.ConversionPattern","%d %c{1} - %m%n");
	
	PropertyConfigurator.configure(prop);
}
 
開發者ID:blackberry,項目名稱:BB-BigData-Log-Tools,代碼行數:26,代碼來源:LogTools.java

示例10: teeOutput

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
private static OutputStream teeOutput(OutputStream capture, OutputStream user) {
    if (user == null) {
        return capture;
    } else {
        return new TeeOutputStream(capture, user);
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:8,代碼來源:ToolingApiGradleExecutor.java

示例11: thenRun

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
/**
 * Runs the function runtime with the specified  class and method
 *
 * @param cls    class to thenRun
 * @param method the method name
 */
public void thenRun(String cls, String method) {
    InputStream oldSystemIn = System.in;
    PrintStream oldSystemOut = System.out;
    PrintStream oldSystemErr = System.err;
    try {
        PrintStream functionOut = new PrintStream(stdOut);
        PrintStream functionErr = new PrintStream(new TeeOutputStream(stdErr, oldSystemErr));
        System.setOut(functionErr);
        System.setErr(functionErr);
        exitStatus = new EntryPoint().run(
                vars,
                pendingInput,
                functionOut,
                functionErr,
                cls + "::" + method);
        stdOut.flush();
        stdErr.flush();
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        System.out.flush();
        System.err.flush();
        System.setIn(oldSystemIn);
        System.setOut(oldSystemOut);
        System.setErr(oldSystemErr);
    }
}
 
開發者ID:fnproject,項目名稱:fdk-java,代碼行數:34,代碼來源:FnTestHarness.java

示例12: createStreamHandler

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
private ExecuteStreamHandler createStreamHandler() throws IOException {
  out = new ByteArrayOutputStream();
  err = new ByteArrayOutputStream();
  PipedOutputStream outPiped = new PipedOutputStream();
  InputStream inPiped = new PipedInputStream(outPiped);
  in = outPiped;

  TeeOutputStream teeOut = new TeeOutputStream(out, System.out);
  TeeOutputStream teeErr = new TeeOutputStream(err, System.err);

  return new PumpStreamHandler(teeOut, teeErr, inPiped);
}
 
開發者ID:SonarSource,項目名稱:sonarlint-cli,代碼行數:13,代碼來源:CommandExecutor.java

示例13: writeContent

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
@Override
byte[] writeContent(OutputStream out) throws IOException {
	ByteArrayOutputStream branch = new ByteArrayOutputStream();
	TeeOutputStream tee = new TeeOutputStream(out, branch);
	writeInt(tag, 1, tee);
	writeInt(valuesCount, 1, tee);
	writeInt(bitmask, 1, tee);
	writeInt(controlByte, 1, tee);
	return branch.toByteArray();
}
 
開發者ID:rrauschenbach,項目名稱:mobi-api4java,代碼行數:11,代碼來源:MobiContentTagEntry.java

示例14: writeContent

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
@Override
byte[] writeContent(OutputStream out) throws IOException {
	ByteArrayOutputStream branch = new ByteArrayOutputStream();
	TeeOutputStream tee = new TeeOutputStream(out, branch);
	writeString(IDENTIFIER, 4, tee);
	writeInt(headerLength, 4, tee);
	writeInt(controlByteCount, 4, tee);
	for (MobiContentTagEntry tag : tags) {
		tag.writeContent(out);
	}
	return branch.toByteArray();
}
 
開發者ID:rrauschenbach,項目名稱:mobi-api4java,代碼行數:13,代碼來源:MobiContentTagx.java

示例15: writeContent

import org.apache.commons.io.output.TeeOutputStream; //導入依賴的package包/類
@Override
byte[] writeContent(OutputStream out) throws IOException {
	ByteArrayOutputStream branch = new ByteArrayOutputStream();
	TeeOutputStream tee = new TeeOutputStream(out, branch);
	writeString(IDENTIFIER, 4, tee);
	writeInt(headerLength, 4, tee);
	writeInt(indexType, 4, tee);
	writeInt(unknown1, 4, tee);
	writeInt(unknown2, 4, tee);
	writeInt(idxtIndex, 4, tee);
	writeInt(indexCount, 4, tee);
	writeInt(indexEncoding, 4, tee);
	writeInt(indexLanguage, 4, tee);
	writeInt(totalIndexCount, 4, tee);
	writeInt(ordtIndex, 4, tee);
	writeInt(ligtIndex, 4, tee);
	writeInt(ordtLigtEntriesCount, 4, tee);
	writeInt(cncxRecordCount, 4, tee);
	write(unknownIndxHeaderPart, out);
	
	if(tagx != null) {
		tagx.writeContent(tee);
	}
	write(rest, out);
	
	return branch.toByteArray();
}
 
開發者ID:rrauschenbach,項目名稱:mobi-api4java,代碼行數:28,代碼來源:MobiContentIndex.java


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