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


Java PrintStream.close方法代码示例

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


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

示例1: runTool

import java.io.PrintStream; //导入方法依赖的package包/类
private String runTool(HdfsConfiguration conf, String[] args, boolean success)
    throws Exception {
  ByteArrayOutputStream o = new ByteArrayOutputStream();
  PrintStream out = new PrintStream(o, true);
  try {
    int ret = ToolRunner.run(new GetConf(conf, out, out), args);
    out.flush();
    System.err.println("Output: " + o.toString());
    assertEquals("Expected " + (success?"success":"failure") +
        " for args: " + Joiner.on(" ").join(args) + "\n" +
        "Output: " + o.toString(),
        success, ret == 0);
    return o.toString();
  } finally {
    o.close();
    out.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestGetConf.java

示例2: 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

示例3: saveGrid

import java.io.PrintStream; //导入方法依赖的package包/类
/**
	Save the grid.
*/
public void saveGrid(File file) throws IOException {
	PrintStream out = new PrintStream(
			new FileOutputStream(file));

	Rectangle rect = grid.getBounds();
	Point p = new Point();

	for (int y=rect.y; y < rect.y+rect.height; y++) {
		p.y = y;
		for (int x=rect.x; x<rect.x+rect.width; x++) {
			p.x = x;
			Point2D p2 = grid.getProjection().getRefXY(p);
			out.println(p2.getX() + "\t" +
						p2.getY() + "\t" +
						grid.valueAt(x,y));
		}
	}
	out.close();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:23,代码来源:Grid2DOverlay.java

示例4: print

import java.io.PrintStream; //导入方法依赖的package包/类
public static void print(String[] bms, PrintStream out) throws IOException {
  Config[] configs = new Config[bms.length];
  for (int j = 0; j < bms.length; j++) {
    InputStream ins = LatexDescriptions.class.getClassLoader().getResourceAsStream("cnf/" + bms[j] + ".cnf");
    configs[j] = Config.parse(ins);
    ins.close();
  }
  for (int i = 0; i < items.length; i++) {
    out.println("\\newcommand{\\bm" + strop(items[i]) + "}[1]{%");
    for (int j = 0; j < bms.length; j++) {
      out.print("\\ifthenelse{\\equal{#1}{" + bms[j] + "}}");
      out.println("{" + configs[j].getDesc(items[i]) + "}{}%");
    }
    out.println("}");
  }
  out.close();
}
 
开发者ID:RuiChen08,项目名称:dacapobench,代码行数:18,代码来源:LatexDescriptions.java

示例5: exportInitialPage

import java.io.PrintStream; //导入方法依赖的package包/类
public void exportInitialPage(File file, String imageName, String networkFilename, int imageWidth, int imageHeight) {
	try {
		PrintStream p = new PrintStream(file);
		p.println("<img src='" + imageName + "' width:" + imageWidth + 
				" height:" + imageHeight + " usemap=#nodes />");
		p.println("<map name='nodes'>");
		for(Vertex v : network.getVertices()) {
			int nodeId = v.getId();
			int distance = 1;
			Point2D loc = layout.transform(v);
			p.println("  <area shape='circle' coords='" + loc.getX() + "," + loc.getY() + "," 
					+ v.getSize() + "' href='" + networkFilename + "?source_node=" + nodeId + 
					"&distance=" + distance + "' alt='" + v.getLabel() + "' title='" + v.getLabel() + "' />");
		}
		p.println("</map>");
		p.close();			
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
		
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:22,代码来源:AppletExporter.java

示例6: testRenameSnapshotCommandWithIllegalArguments

import java.io.PrintStream; //导入方法依赖的package包/类
@Test
public void testRenameSnapshotCommandWithIllegalArguments() throws Exception {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  PrintStream psOut = new PrintStream(out);
  System.setOut(psOut);
  System.setErr(psOut);
  FsShell shell = new FsShell();
  shell.setConf(conf);
  
  String[] argv1 = {"-renameSnapshot", "/tmp", "s1"};
  int val = shell.run(argv1);
  assertTrue(val == -1);
  assertTrue(out.toString().contains(
      argv1[0] + ": Incorrect number of arguments."));
  out.reset();
  
  String[] argv2 = {"-renameSnapshot", "/tmp", "s1", "s2", "s3"};
  val = shell.run(argv2);
  assertTrue(val == -1);
  assertTrue(out.toString().contains(
      argv2[0] + ": Incorrect number of arguments."));
  psOut.close();
  out.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestSnapshotRename.java

示例7: saveProperties

import java.io.PrintStream; //导入方法依赖的package包/类
public static void saveProperties(Map<String, String> map, File file, String encoding) throws IOException {
	PrintStream ps = new PrintStream(file, encoding);
	for (Entry<String, String> entry : map.entrySet()) {
		ps.println(entry.getKey());
		ps.println(entry.getValue());
		ps.println();
	}
	ps.close();
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:10,代码来源:FileUtils.java

示例8: printResults

import java.io.PrintStream; //导入方法依赖的package包/类
private void printResults(String[] passLines, String[] refLines, List<Result> results, File diffFile) throws IOException {
    int numLength = (refLines.length > passLines.length) ? String.valueOf(refLines.length).length() :
        String.valueOf(passLines.length).length();
    PrintStream ps = new PrintStream(new FileOutputStream(diffFile));
    boolean precontext=false;
    for (int i = 0; i < results.size(); i++) {
        Result rs = results.get(i);
        if (!precontext) {
            int si = rs.passIndex-contextLines;
            if (si < 0) si = 0;
            for (int j=si;j < rs.passIndex;j++) {
                printContext(passLines, ps, j, numLength);
            }
        } else {
            precontext=false;
        }
        results.get(i).print(passLines, refLines, ps, numLength);
        int e1 = (rs.newLine) ? rs.passIndex : rs.end;
        int e2 = e1+contextLines;
        if (i < results.size()-1 && results.get(i+1).passIndex < e2) {
            e2 = results.get(i+1).passIndex;
            precontext=true;
        } else if (e2 > passLines.length) {
            e2=passLines.length;
        }
        for (int j=e1;j < e2;j++) {
            printContext(passLines, ps, j, numLength);
        }
    }
    ps.close();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:LineDiff.java

示例9: closePrintStream

import java.io.PrintStream; //导入方法依赖的package包/类
/**
 * Closes the given print stream, or closes it if is the standard output.
 * @param printStream
 */
private void closePrintStream(PrintStream printStream)
{
    if (printStream == System.out)
    {
        printStream.flush();
    }
    else
    {
        printStream.close();
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:16,代码来源:ProGuard.java

示例10: execCmd

import java.io.PrintStream; //导入方法依赖的package包/类
static String execCmd(FsShell shell, String... args) throws Exception {
  ByteArrayOutputStream baout = new ByteArrayOutputStream();
  PrintStream out = new PrintStream(baout, true);
  PrintStream old = System.out;
  System.setOut(out);
  shell.run(args);
  out.close();
  System.setOut(old);
  return baout.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestCopyFiles.java

示例11: testRelease

import java.io.PrintStream; //导入方法依赖的package包/类
public void testRelease() throws Exception {
    FieldLNCache fc = new FieldLNCache();
    File testFile = File.createTempFile("test", "tst");
    testFile.deleteOnExit();
    FileObject testFO = FileUtil.toFileObject(testFile);
    fc.putLine("testURL", "testClass", "testField", testFO, 42);
    assertEquals(new Integer(42), fc.getLine("testURL", "testClass", "testField"));
    assertNull(fc.getLine("testURL", "testClass", "testField2"));
    
    WeakReference testFORef = new WeakReference(testFO);
    testFO = null;
    assertGC("FileObject", testFORef);
    assertNull(fc.getLine("testURL", "testClass", "testField"));
    
    testFO = FileUtil.toFileObject(testFile);
    assertNull(fc.getLine("testURL", "testClass", "testField"));
    fc.putLine("testURL", "testClass", "testField", testFO, 42);
    assertEquals(new Integer(42), fc.getLine("testURL", "testClass", "testField"));
    PrintStream printStream = new PrintStream(testFO.getOutputStream());
    printStream.print("Changed.");
    printStream.close();
    assertNull(fc.getLine("testURL", "testClass", "testField")); // is reset after change
    
    fc.putLine("testURL", "testClass", "testField", testFO, 43);
    assertEquals(new Integer(43), fc.getLine("testURL", "testClass", "testField"));
    testFO.delete();
    assertNull(fc.getLine("testURL", "testClass", "testField"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:FieldLNCacheTest.java

示例12: writeProxies

import java.io.PrintStream; //导入方法依赖的package包/类
protected void writeProxies() {
	try {
		PrintStream out = new PrintStream(proxyFile);
		for (String s : proxies)
			out.println(s);
		out.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:11,代码来源:MapApp.java

示例13: computeExcitationToOutputCell

import java.io.PrintStream; //导入方法依赖的package包/类
float computeExcitationToOutputCell(int omcx, int omcy) {
            // For all subunits, excluding the edge ones and the last ones (far right and bottom)
            // Select computation type
            excitationArray[omcx][omcy] = 0;
            if (!exponentialToTanh) {// Use non-linear model (given the nonlinearity order)
                // Average of 4 central cells
                for (int x = omcx; x <= (omcx + 1); x++) {
                    for (int y = omcy; y <= (omcy + 1); y++) {
                        //if(Math.pow(subunits[x][y].computeInputToCell(),nonLinearityOrder) < Saturation){
                        //    excitationArray[omcx][omcy] += (float) Math.pow(subunits[x][y].computeInputToCell(),nonLinearityOrder);
                        //}
                        if ((synapticWeight * synapticWeight * subunits[x][y].computeInputToCell() * subunits[x][y].computeInputToCell()) < Saturation) {
                            excitationArray[omcx][omcy] += synapticWeight * synapticWeight * subunits[x][y].computeInputToCell() * subunits[x][y].computeInputToCell();
                        } else {
                            excitationArray[omcx][omcy] += Saturation;
                        }
                    }
                }
                excitationArray[omcx][omcy] /= 4;
            } // Ignore surround
            else { // Use tanh model (given saturation value): preferred method
                // Average of 4 central cells
                excitationArray[omcx][omcy] = (float) ((Saturation * Math.tanh((synapticWeight * subunits[omcx][omcy].computeInputToCell())))
                        + (Saturation * Math.tanh((synapticWeight * subunits[omcx + 1][omcy + 1].computeInputToCell())))
                        + (Saturation * Math.tanh((synapticWeight * subunits[omcx + 1][omcy].computeInputToCell())))
                        + (Saturation * Math.tanh((synapticWeight * subunits[omcx][omcy + 1].computeInputToCell())))) / 4;
            } // Ignore surround
//------------------------------------------------------------------------------
            // Log excitationArray
            if (startLogging == true) {
                try {
                    if ((omcx == 0) && (omcy == 0)) {
                        // Create a new file output stream
                        FileOutputStream streamOut = new FileOutputStream(new File("C:\\Users\\Diederik Paul Moeys\\Desktop\\excitationArray.txt"), true);
                        // Connect print stream to the output stream
                        p = new PrintStream(streamOut);
                        p.print(excitationArray[omcx][omcy]);
                        p.print(", ");
                        p.print(omcx);
                        p.print(", ");
                        p.print(omcy);
                        p.print(", ");
                        p.println(lastUpdateTimestamp);
                        p.close();
                    }
                } catch (Exception e) {
                    System.err.println("Error writing to file");
                }
            }
            if (deleteLogging == true) {
                File fout = new File("C:\\Users\\Diederik Paul Moeys\\Desktop\\excitationArray.txt");
                fout.delete();
            }
            excitationArray[omcx][omcy] = centerExcitationToSurroundInhibitionRatio * excitationArray[omcx][omcy];
            return excitationArray[omcx][omcy];
        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:57,代码来源:OMCOD.java

示例14: process

import java.io.PrintStream; //导入方法依赖的package包/类
@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
	CompareElementsResolvedObjects resObj = getResolvedObjects();
	Logger logger = getLogger(ctx);
	EvaluationContext evalCtx = new EvaluationContext(logger);
	double globalReferenceScore = 0;
	int nReference = 0;
	double globalPredictedScore = 0;
	int nPredicted = 0;
	PrintStream out = getOutStream();
	for (Element elt : Iterators.loop(resObj.sections.evaluateElements(evalCtx, corpus))) {
		List<ElementMatch> referenceMatch = match(evalCtx, elt, resObj.reference, resObj.predicted);
		List<ElementMatch> predictedMatch = match(evalCtx, elt, resObj.predicted, resObj.reference);
		nReference += referenceMatch.size();
		nPredicted += predictedMatch.size();
		double referenceScore = sum(referenceMatch);
		double predictedScore = sum(predictedMatch);
		globalReferenceScore += referenceScore;
		globalPredictedScore += predictedScore;
		double recall = referenceScore / referenceMatch.size();
		double precision = predictedScore / predictedMatch.size();
		double fScore = fScore(precision, recall);
		
		out.println(elt.toString());
		if (showRecall) {
			out.println("    Reference matches (" + referenceMatch.size() + ") :");
			printMatches(out, evalCtx, referenceMatch);
		}
		if (showPrecision) {
			out.println("    Predicted matches (" + predictedMatch.size() + ") :");
			printMatches(out, evalCtx, predictedMatch);
		}
		if (showRecall)
			out.println("    Recall   : " + recall);
		if (showPrecision)
			out.println("    Precision: " + precision);
		if (showRecall && showPrecision)
			out.println("    F-Score  : " + fScore);
		out.println();
		out.println();
	}
	double globalRecall = globalReferenceScore / nReference;
	double globalPrecision = globalPredictedScore / nPredicted;
	double globalFScore = fScore(globalRecall, globalPrecision);
	out.println("Global results");
	if (showRecall)
		out.println("    Recall   : " + globalRecall);
	if (showPrecision)
		out.println("    Precision: " + globalPrecision);
	if (showRecall && showPrecision)
		out.println("    F-Score  : " + globalFScore);
	out.close();
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:54,代码来源:CompareElements.java

示例15: closeAllStreams

import java.io.PrintStream; //导入方法依赖的package包/类
private void closeAllStreams() {
    for (PrintStream ps : logStreamTable.values()) {
        ps.close();
    }
    logStreamTable.clear();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:NbTestCase.java


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