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


Java PrintWriter.flush方法代码示例

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


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

示例1: handle

import java.io.PrintWriter; //导入方法依赖的package包/类
public void handle(String s, Request request, HttpServletRequest httpServletRequest,
    HttpServletResponse response) throws IOException, ServletException {
  /*
  * Writing the response, for the stats request over netty
  */
  System.out.println("New Statrequest!");
  response.setContentType("application/json; charset=UTF-8");
  PrintWriter printout = response.getWriter();
  JSONObject JObject = new JSONObject();
  JObject.put("down", "1000");
  JObject.put("up", "300");

  printout.print(JObject);
  printout.flush();

}
 
开发者ID:Sigma-News,项目名称:Backend,代码行数:17,代码来源:StatsHandler.java

示例2: run

import java.io.PrintWriter; //导入方法依赖的package包/类
/**
 * Simple API entry point.
 * @param args Options and operands for doclint
 * @throws BadArgs if an error is detected in any args
 * @throws IOException if there are problems with any of the file arguments
 */
public void run(String... args) throws BadArgs, IOException {
    PrintWriter out = new PrintWriter(System.out);
    try {
        run(out, args);
    } finally {
        out.flush();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:DocLint.java

示例3: printNotice

import java.io.PrintWriter; //导入方法依赖的package包/类
/**
 * Print a message.
 * Part of DocErrorReporter.
 *
 * @param pos the position where the error occurs
 * @param msg message to print
 */
public void printNotice(SourcePosition pos, String msg) {
    if (diagListener != null) {
        report(DiagnosticType.NOTE, pos, msg);
        return;
    }

    PrintWriter noticeWriter = getWriter(WriterKind.NOTICE);
    if (pos == null)
        noticeWriter.println(msg);
    else
        noticeWriter.println(pos + ": " + msg);
    noticeWriter.flush();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Messager.java

示例4: setUpNegativeCustomLocation

import java.io.PrintWriter; //导入方法依赖的package包/类
private void setUpNegativeCustomLocation() throws Exception {
	File buildFile = testProjectDir.newFile("build.gradle");
	PrintWriter printWriter = new PrintWriter(buildFile);
	printWriter.println("plugins { id 'com.tts.scp-neo-plugin' version '0.0.2' } ");
	printWriter.println("scpSettings { sdkVersion = '3.39.10' ");
	printWriter.println("sdkLocation = '' }");
	printWriter.println("repositories { mavenCentral()	}");
	printWriter.flush();
	printWriter.close();
}
 
开发者ID:TTS-TMC,项目名称:neo-java-web-gradle-plugin,代码行数:11,代码来源:InstallSdkTest.java

示例5: asString

import java.io.PrintWriter; //导入方法依赖的package包/类
public static String asString() {
  StringWriter sw = new StringWriter(256);
  PrintWriter pw = new PrintWriter(sw);
  print(pw);
  pw.flush();
  return sw.toString();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:GemFireVersion.java

示例6: countGoodsNumByCategoryId

import java.io.PrintWriter; //导入方法依赖的package包/类
@RequestMapping("/webloginAJ")
public void countGoodsNumByCategoryId(HttpServletRequest request, HttpServletResponse response) {
    response.setContentType("text/piain;charset=Utf-8");
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);


    HttpJson json = new HttpJson();
    json.setStatusCode(400);
    json.setMessage("testMessage");
    json.constractJsonString();

    try {
        PrintWriter out = response.getWriter();
        String jsonpCallback = request.getParameter("jsonpCallback");// 客户端请求
        JSONObject object = new JSONObject();
        List<Login> send = new ArrayList<>();
        for (Integer i = 0; i < 3; i++) {
            Login thisl = new Login();
            thisl.setUAName(i.toString() + "啦啦啦啦");
            send.add(thisl);
        }
        object.put("list", send);
        out.println(jsonpCallback + "(" + object.toString() + ")");// 返回jsonp格式数据
        out.flush();
        out.close();
    } catch (IOException e) {
        System.out.println(e.getMessage());
    }
}
 
开发者ID:okingjerryo,项目名称:WeiMusicCommunity-server,代码行数:32,代码来源:WebController.java

示例7: deliverStackTrace

import java.io.PrintWriter; //导入方法依赖的package包/类
private static void deliverStackTrace(Throwable t, AntEvent originalEvent) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    t.printStackTrace(pw);
    pw.flush();
    deliverBlockOfTextAsLines(sw.toString(), originalEvent, AntEvent.LOG_ERR);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:StandardLogger.java

示例8: doClose

import java.io.PrintWriter; //导入方法依赖的package包/类
@Override
public void doClose(Object writeObject) throws IOException
{
    setContentType(writeObject);
    PrintWriter printWriter = response.getWriter();
    printWriter.print(writeObject);
    printWriter.flush();
    printWriter.close();
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:10,代码来源:WServletResponse.java

示例9: addVersionInfo

import java.io.PrintWriter; //导入方法依赖的package包/类
public void addVersionInfo() {
    Properties props = new Properties();
    // when running from webstart  we are not allowed to open a file on the local file system, but we can
    // get a the contents of a resource, which in this case is the echo'ed date stamp written by ant on the last build
    ClassLoader cl = this.getClass().getClassLoader(); // get this class'es class loader
    addLogInfo("\nLoading version info from resource " + AEViewerAboutDialog.VERSION_FILE);
    URL versionURL = cl.getResource(AEViewerAboutDialog.VERSION_FILE); // get a URL to the time stamp file
    addLogInfo("\nVersion URL=" + versionURL + "\n");

    if (versionURL != null) {
        try {
            Object urlContents = versionURL.getContent();
            BufferedReader in = null;
            if (urlContents instanceof InputStream) {
                props.load((InputStream) urlContents);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
        PrintWriter ps = new PrintWriter(baos);
        props.list(ps);
        ps.flush();
        try {
            addLogInfo("\n" + baos.toString("UTF-8"));
        } catch (UnsupportedEncodingException ex) {
            System.err.println("cannot encode version information in LoggingWindow.addVersionInfo: " + ex.toString());
        }
    } else {
        props.setProperty("version", "missing file " + AEViewerAboutDialog.VERSION_FILE + " in jAER.jar");
    }

}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:34,代码来源:LoggingWindow.java

示例10: metaSave

import java.io.PrintWriter; //导入方法依赖的package包/类
/**
 * Dump all metadata into specified file
 */
void metaSave(String filename) throws IOException {
  checkSuperuserPrivilege();
  checkOperation(OperationCategory.UNCHECKED);
  writeLock();
  try {
    checkOperation(OperationCategory.UNCHECKED);
    File file = new File(System.getProperty("hadoop.log.dir"), filename);
    PrintWriter out = new PrintWriter(new BufferedWriter(
        new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8)));
    metaSave(out);
    out.flush();
    out.close();
  } finally {
    writeUnlock();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:FSNamesystem.java

示例11: main

import java.io.PrintWriter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    PrintWriter out = new PrintWriter(System.out, true);
    JavacTool tool = JavacTool.create();
    try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
        File testSrc = new File(System.getProperty("test.src"));
        Iterable<? extends JavaFileObject> f =
            fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "T6345974.java")));
        JavacTask task = tool.getTask(out, fm, null, null, null, f);
        Iterable<? extends CompilationUnitTree> trees = task.parse();
        out.flush();

        Scanner s = new Scanner();
        for (CompilationUnitTree t: trees)
            s.scan(t, null);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:T6345974.java

示例12: exception2String

import java.io.PrintWriter; //导入方法依赖的package包/类
private String exception2String(Throwable e) {

        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw, true);
        e.printStackTrace(pw);
        pw.flush();
        sw.flush();

        return sw.toString();
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:11,代码来源:Logger.java

示例13: log

import java.io.PrintWriter; //导入方法依赖的package包/类
public void log(String str, Throwable t)
{
	PrintWriter writer = DriverManager.getLogWriter();
	if (writer == null)
	{
		return;
	}

	synchronized (this)
	{
		buffer.setLength(0);
		dateFormat.format(new Date(), buffer, dummyPosition);
		buffer.append(connectionIDString);
		buffer.append(str);

		// synchronize to ensure that the exception (if any) does
		// not get split up from the corresponding log message
		synchronized (writer)
		{
			writer.println(buffer.toString());
			if (t != null)
			{
				t.printStackTrace(writer);
			}
		}
		writer.flush();
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:29,代码来源:Logger.java

示例14: printImpl

import java.io.PrintWriter; //导入方法依赖的package包/类
private Object printImpl(final boolean newLine, final Object... objects) {
    @SuppressWarnings("resource")
    final PrintWriter out = scontext != null? new PrintWriter(scontext.getWriter()) : getContext().getEnv().getOut();
    final StringBuilder sb = new StringBuilder();

    for (final Object obj : objects) {
        if (sb.length() != 0) {
            sb.append(' ');
        }

        sb.append(JSType.toString(obj));
    }

    // Print all at once to ensure thread friendly result.
    if (newLine) {
        out.println(sb.toString());
    } else {
        out.print(sb.toString());
    }

    out.flush();

    return UNDEFINED;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Global.java

示例15: onAccessDenied

import java.io.PrintWriter; //导入方法依赖的package包/类
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
	HttpServletRequest req = (HttpServletRequest) request;
	HttpServletResponse res = (HttpServletResponse) response;
	if(isAsynRequest(req, res)){
		WebUtils.toHttp(response).sendError(HttpServletResponse.SC_UNAUTHORIZED);
		Result<Object> result = new Result<Object>();
		result.setCode("401");
		result.setSuccess(false);
		result.setMessage(Messages.getMessage(getDefaultNoPermissionMessageI18nCode(), null, getDefaultNoPermissionMessage()));
		res.setCharacterEncoding("UTF-8");
		res.setContentType("application/json;charset=UTF-8");
		PrintWriter out = res.getWriter();
		out.println(JsonUtils.object2Json(result));
		out.flush();
		out.close();
		return false;
	}else{
		return super.onAccessDenied(request, response);
	}
}
 
开发者ID:penggle,项目名称:xproject,代码行数:21,代码来源:GlobalFormAuthenticationFilter.java


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