当前位置: 首页>>代码示例>>Java>>正文


Java PrintStream类代码示例

本文整理汇总了Java中java.io.PrintStream的典型用法代码示例。如果您正苦于以下问题:Java PrintStream类的具体用法?Java PrintStream怎么用?Java PrintStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PrintStream类属于java.io包,在下文中一共展示了PrintStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PluginPrinter

import java.io.PrintStream; //导入依赖的package包/类
/**
 * This is called from the Java Plug-in to print an Applet's
 * contents as EPS to a postscript stream provided by the browser.
 * @param applet the applet component to print.
 * @param stream the print stream provided by the plug-in
 * @param x the x location of the applet panel in the browser window
 * @param y the y location of the applet panel in the browser window
 * @param w the width of the applet panel in the browser window
 * @param h the width of the applet panel in the browser window
 */
public PluginPrinter(Component applet,
                     PrintStream stream,
                     int x, int y, int w, int h) {

    this.applet = applet;
    this.epsTitle = "Java Plugin Applet";
    this.stream = stream;
    bx = x;
    by = y;
    bw = w;
    bh = h;
    width = applet.size().width;
    height = applet.size().height;
    epsPrinter = new EPSPrinter(this, epsTitle, stream,
                                0, 0, width, height);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:PSPrinterJob.java

示例2: testShortFile

import java.io.PrintStream; //导入依赖的package包/类
@Test
public void testShortFile() throws Exception {
  // short file: 2 characters worth (shorter than the UTF-8 BOM), without BOMs
  File testFolder = tempDir.newFolder("testShortFilesFolder");
  File testFile2 = new File(testFolder, "twobyte.csv");
  PrintStream p2 = new PrintStream(testFile2);
  p2.print("y\n");
  p2.close();

  testBuilder()
    .sqlQuery(String.format("select * from table(dfs.`%s` (type => 'text', " +
        "fieldDelimiter => ',', lineDelimiter => '\n', extractHeader => true)) ",
      testFile2.getAbsolutePath()))
    .unOrdered()
    .baselineColumns("y")
    .expectsEmptyResultSet()
    .go();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:TestNewTextReader.java

示例3: testImportMain

import java.io.PrintStream; //导入依赖的package包/类
/**
 * test main method. Import should print help and call System.exit
 */
@Test
public void testImportMain() throws Exception {
  PrintStream oldPrintStream = System.err;
  SecurityManager SECURITY_MANAGER = System.getSecurityManager();
  LauncherSecurityManager newSecurityManager= new LauncherSecurityManager();
  System.setSecurityManager(newSecurityManager);
  ByteArrayOutputStream data = new ByteArrayOutputStream();
  String[] args = {};
  System.setErr(new PrintStream(data));
  try {
    System.setErr(new PrintStream(data));
    Import.main(args);
    fail("should be SecurityException");
  } catch (SecurityException e) {
    assertEquals(-1, newSecurityManager.getExitCode());
    assertTrue(data.toString().contains("Wrong number of arguments:"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dimport.filter.class=<name of filter class>"));
    assertTrue(data.toString().contains("-Dimport.bulk.output=/path/for/output"));
    assertTrue(data.toString().contains("-Dmapreduce.reduce.speculative=false"));
  } finally {
    System.setErr(oldPrintStream);
    System.setSecurityManager(SECURITY_MANAGER);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestImportExport.java

示例4: printSentence

import java.io.PrintStream; //导入依赖的package包/类
protected void printSentence(PrintStream out, StringBuilder sb, Layer sentence, boolean withPos) {
	boolean notFirst = false;
	for (Annotation word : sentence) {
		String form = word.getLastFeature(formFeatureName);
		if (form.isEmpty())
			continue;
		sb.setLength(0);
		if (notFirst)
			sb.append(' ');
		else
			notFirst = true;
		Strings.escapeWhitespaces(sb, form, '|', '.');
		if (withPos) {
			sb.append('|');
			sb.append(word.getLastFeature(posFeatureName));
		}
		out.print(sb);
	}
	out.println();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:21,代码来源:CCGBase.java

示例5: exec

import java.io.PrintStream; //导入依赖的package包/类
@Override
public ExitCode exec(PrintStream out) throws CannotCreateSessionException,
        PermissionDeniedException, ServerError {
    client c = newClient();
    ServiceFactoryPrx serviceFactory = c.createSession();
    serviceFactory.setSecurityPassword(password);

    Session initialSession = serviceFactory.getSessionService()
                            .getSession(c.getSessionId());
    Session newSession = serviceFactory.getSessionService()
                        .createUserSession(0,
                                timeToIdle(initialSession),
                                group(initialSession));
    c.killSession();  // close initial session.

    out.print(newSession.getUuid().getValue());

    return ExitCode.Ok;
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:20,代码来源:Create.java

示例6: run

import java.io.PrintStream; //导入依赖的package包/类
public void run() throws IOException {
    final TargetMonitor monitor = useSocketMonitor
            ? TargetMonitor.await(monitorPort)
            : TargetMonitor.forPrintStream(System.out);

    PrintStream monitorPrintStream = new PrintStreamDecorator(System.out) {
        @Override public void print(String str) {
            monitor.output(str != null ? str : "null");
        }
    };
    System.setOut(monitorPrintStream);
    System.setErr(monitorPrintStream);

    try {
        run(monitor);
    } catch (Throwable internalError) {
        internalError.printStackTrace(monitorPrintStream);
    } finally {
        monitor.close();
    }
}
 
开发者ID:dryganets,项目名称:vogar,代码行数:22,代码来源:TestRunner.java

示例7: testFAttrs

import java.io.PrintStream; //导入依赖的package包/类
public void testFAttrs() throws Exception {
    FileObject resolver = FileUtil.createData(FileUtil.getConfigRoot(), "Services/MIMEResolver/r.xml");
    resolver.setAttribute("position", 2);
    OutputStream os = resolver.getOutputStream();
    PrintStream ps = new PrintStream(os);
    ps.println("<!DOCTYPE MIME-resolver PUBLIC '-//NetBeans//DTD MIME Resolver 1.0//EN' 'http://www.netbeans.org/dtds/mime-resolver-1_0.dtd'>");
    ps.println("<MIME-resolver>");
    ps.println(" <file>");
    ps.println("  <fattr name='foo' text='yes'/>");
    ps.println("  <resolver mime='text/x-boo'/>");
    ps.println(" </file>");
    ps.println("</MIME-resolver>");
    os.close();
    FileObject foo = FileUtil.createMemoryFileSystem().getRoot().createData("somefile");
    assertEquals("content/unknown", foo.getMIMEType());
    foo.setAttribute("foo", Boolean.FALSE);
    assertEquals("content/unknown", foo.getMIMEType());
    foo.setAttribute("foo", "no");
    assertEquals("content/unknown", foo.getMIMEType());
    foo.setAttribute("foo", "yes");
    assertEquals("text/x-boo", foo.getMIMEType());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MIMESupportTest.java

示例8: stop

import java.io.PrintStream; //导入依赖的package包/类
protected void stop() {
    PrintStream printStream = new PrintStream(out);
    printStream.println("stop");
    printStream.flush();
    printStream.close();
    restartItem.setEnabled(false);
    stopItem.setEnabled(false);
    startItem.setEnabled(true);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:10,代码来源:Manager.java

示例9: CommandProcessor

import java.io.PrintStream; //导入依赖的package包/类
public CommandProcessor(DebuggerInterface debugger, BufferedReader in, PrintStream out, PrintStream err) {
    this.debugger = debugger;
    this.agent = debugger.getAgent();
    this.in = in;
    this.out = out;
    this.err = err;
    for (int i = 0; i < commandList.length; i++) {
        Command c = commandList[i];
        if (commands.get(c.name) != null) {
            throw new InternalError(c.name + " has multiple definitions");
        }
        commands.put(c.name, c);
    }
    if (debugger.isAttached()) {
        postAttach();
    }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:18,代码来源:CommandProcessor.java

示例10: printTo

import java.io.PrintStream; //导入依赖的package包/类
private void printTo(PrintStream ps, int num_args) {
	// print items from the top of the stack
	// # of items
	if (num_args == 0) {
		// display $0
		ps.println(jrt.jrtGetInputField(0));
	} else {
		// cache $OFS to separate fields below
		// (no need to execute getOFS for each field)
		String ofs_string = getOFS().toString();
		for (int i = 0; i < num_args; i++) {
			String s = JRT.toAwkStringForOutput(pop(), getOFMT().toString());
			ps.print(s);
			// if more elements, display $FS
			if (i < num_args - 1) {
				// use $OFS to separate fields
				ps.print(ofs_string);
			}
		}
		ps.println();
	}
	// for now, since we are not using Process.waitFor()
	if (IS_WINDOWS) {
		ps.flush();
	}
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:27,代码来源:AVM.java

示例11: BytesOf

import java.io.PrintStream; //导入依赖的package包/类
/**
 * Ctor.
 * @param error The exception to serialize
 * @param charset Charset
 */
public BytesOf(final Throwable error, final CharSequence charset) {
    this(
        () -> {
            try (
                final ByteArrayOutputStream baos =
                    new ByteArrayOutputStream()
            ) {
                error.printStackTrace(
                    new PrintStream(baos, true, charset.toString())
                );
                return baos.toByteArray();
            }
        }
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:21,代码来源:BytesOf.java

示例12: writeInput

import java.io.PrintStream; //导入依赖的package包/类
private void writeInput(Corpus corpus) throws IOException {
	EvaluationContext evalCtx = new EvaluationContext(logger);
	WapitiResolvedObjects resObj = getResolvedObjects();
	try (PrintStream ps = new PrintStream(inputFile)) {
		for (Section sec : Iterators.loop(sectionIterator(evalCtx, corpus))) {
			for (Layer sentence : sec.getSentences(tokenLayerName, sentenceLayerName)) {
				for (Annotation a : sentence) {
					boolean notFirst = false;
					for (Evaluator feat : resObj.features) {
						if (notFirst) {
							ps.print('\t');
						}
						else {
							notFirst = true;
						}
						String value = feat.evaluateString(evalCtx, a);
						ps.print(value);
					}
					ps.println();
				}
				ps.println();
			}
		}
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:26,代码来源:AbstractWapiti.java

示例13: processMultipleStorageTypesContent

import java.io.PrintStream; //导入依赖的package包/类
private void processMultipleStorageTypesContent(boolean quotaUsageOnly)
  throws Exception {
  Path path = new Path("mockfs:/test");

  when(mockFs.getFileStatus(eq(path))).thenReturn(fileStat);
  PathData pathData = new PathData(path.toString(), conf);

  PrintStream out = mock(PrintStream.class);

  Count count = new Count();
  count.out = out;

  LinkedList<String> options = new LinkedList<String>();
  options.add(quotaUsageOnly ? "-u" : "-q");
  options.add("-t");
  options.add("SSD,DISK");
  options.add("dummy");
  count.processOptions(options);
  count.processPath(pathData);
  String withStorageType = BYTES + StorageType.SSD.toString()
      + " " + StorageType.DISK.toString() + " " + pathData.toString();
  verify(out).println(withStorageType);
  verifyNoMoreInteractions(out);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:25,代码来源:TestCount.java

示例14: writeSentence

import java.io.PrintStream; //导入依赖的package包/类
private void writeSentence(PrintStream ps, Layer sent) {
	boolean notFirst = false;
	for (Annotation word : sent) {
		if (notFirst) {
			ps.print(' ');
		}
		else {
			notFirst = true;
		}
		writeToken(ps, word.getLastFeature(enjuParser.getWordFormFeatureName()));
		if (word.hasFeature(enjuParser.getPosFeatureName())) {
			ps.print('/');
			writeToken(ps, word.getLastFeature(enjuParser.getPosFeatureName()));
		}
	}
	ps.println();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:18,代码来源:EnjuExternal.java

示例15: write

import java.io.PrintStream; //导入依赖的package包/类
@Override
public void write(Collection<Rule> rules) {
  try (PrintStream workspaceStream = new PrintStream(workspaceFile);
      PrintStream buildStream = new PrintStream(buildFile)) {
    writeWorkspace(workspaceStream, rules);
    writeBuild(buildStream, rules);
  } catch (IOException e) {
    logger.severe(
        "Could not write WORKSPACE and BUILD files to " + buildFile.getParent() + ": "
            + e.getMessage());
    return;
  }
  System.err.println("Wrote:\n" + workspaceFile + "\n" + buildFile);
}
 
开发者ID:bazelbuild,项目名称:migration-tooling,代码行数:15,代码来源:WorkspaceWriter.java


注:本文中的java.io.PrintStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。