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


Java PrintWriter.print方法代码示例

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


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

示例1: doGet

import java.io.PrintWriter; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");
    if (!useChunks) {
        // Longer than it needs to be because response will fail before
        // it is complete
        resp.setContentLength(100);
    }
    PrintWriter pw = resp.getWriter();
    pw.print("line01");
    pw.flush();
    resp.flushBuffer();
    pw.print("line02");
    pw.flush();
    resp.flushBuffer();
    pw.print("line03");

    // Now throw a RuntimeException to end this request
    throw new ServletException("Deliberate failure");
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:24,代码来源:TestAbstractHttp11Processor.java

示例2: doGet

import java.io.PrintWriter; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    resp.setContentType("text/plain;UTF-8");
    PrintWriter out = resp.getWriter();

    try {
        Context ctx = new InitialContext();
        Object obj = ctx.lookup("java:comp/env/bug50351");
        TesterObject to = (TesterObject) obj;
        out.print(to.getFoo());
    } catch (NamingException ne) {
        ne.printStackTrace(out);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestNamingContext.java

示例3: printThread

import java.io.PrintWriter; //导入方法依赖的package包/类
private static void printThread(ThreadInfo ti, PrintWriter out) {
  out.print("\"" + ti.getThreadName() + "\"" + " Id="
      + ti.getThreadId() + " in " + ti.getThreadState());
  if (ti.getLockName() != null) {
    out.print(" on lock=" + ti.getLockName());
  }
  if (ti.isSuspended()) {
    out.print(" (suspended)");
  }
  if (ti.isInNative()) {
    out.print(" (running in native)");
  }
  out.println();
  if (ti.getLockOwnerName() != null) {
    out.println(INDENT + " owned by " + ti.getLockOwnerName() + " Id="
        + ti.getLockOwnerId());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TimedOutTestsListener.java

示例4: readBranch

import java.io.PrintWriter; //导入方法依赖的package包/类
private int readBranch (int index, String indent, String name, String disName, TypedefEntry entry, PrintWriter stream)
{
    SymtabEntry type = entry.type ();
    Util.writeInitializer (indent, '_' + name, "", entry, stream);

    if (!entry.arrayInfo ().isEmpty () ||
        type instanceof SequenceEntry ||
        type instanceof PrimitiveEntry ||
        type instanceof StringEntry) {
        index = ((JavaGenerator)entry.generator ()).read (index, indent, '_' + name, entry, stream);
    } else {
        stream.println (indent + '_' + name + " = " + Util.helperName (type, true) + ".read (istream);");
    }

    stream.print (indent + "value." + name + " (");
    if( disName == "" )
        stream.println("_" + name + ");");
    else
        stream.println(disName + ", " + "_" + name + ");");

    return index;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:UnionGen.java

示例5: testGetClusterNodeLabelsWithLocalAccess

import java.io.PrintWriter; //导入方法依赖的package包/类
@Test
public void testGetClusterNodeLabelsWithLocalAccess() throws Exception {
  YarnClient client = mock(YarnClient.class);
  when(client.getClusterNodeLabels()).thenReturn(
      ImmutableSet.of("remote1", "remote2"));
  ClusterCLI cli = new ClusterCLI();
  cli.setClient(client);
  cli.setSysOutPrintStream(sysOut);
  cli.setSysErrPrintStream(sysErr);
  ClusterCLI.localNodeLabelsManager = mock(CommonNodeLabelsManager.class);
  when(ClusterCLI.localNodeLabelsManager.getClusterNodeLabels())
      .thenReturn(ImmutableSet.of("local1", "local2"));

  int rc =
      cli.run(new String[] { ClusterCLI.CMD,
          "-" + ClusterCLI.LIST_LABELS_CMD,
          "-" + ClusterCLI.DIRECTLY_ACCESS_NODE_LABEL_STORE });
  assertEquals(0, rc);

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintWriter pw = new PrintWriter(baos);
  // it should return local* instead of remote*
  pw.print("Node Labels: local1,local2");
  pw.close();
  verify(sysOut).println(baos.toString("UTF-8"));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestClusterCLI.java

示例6: dumpConf

import java.io.PrintWriter; //导入方法依赖的package包/类
@Override
public void dumpConf(PrintWriter pwriter) {
    super.dumpConf(pwriter);

    pwriter.print("initLimit=");
    pwriter.println(self.getInitLimit());
    pwriter.print("syncLimit=");
    pwriter.println(self.getSyncLimit());
    pwriter.print("electionAlg=");
    pwriter.println(self.getElectionType());
    pwriter.print("electionPort=");
    pwriter.println(self.getElectionAddress().getPort());
    pwriter.print("quorumPort=");
    pwriter.println(self.getQuorumAddress().getPort());
    pwriter.print("peerType=");
    pwriter.println(self.getLearnerType().ordinal());
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:18,代码来源:ReadOnlyZooKeeperServer.java

示例7: dumpViewHierarchy

import java.io.PrintWriter; //导入方法依赖的package包/类
private void dumpViewHierarchy(String prefix, PrintWriter writer, View view) {
    writer.print(prefix);
    if (view == null) {
        writer.println("null");
        return;
    }
    writer.println(viewToString(view));
    if (view instanceof ViewGroup) {
        ViewGroup grp = (ViewGroup) view;
        int N = grp.getChildCount();
        if (N > 0) {
            prefix = prefix + "  ";
            for (int i = 0; i < N; i++) {
                dumpViewHierarchy(prefix, writer, grp.getChildAt(i));
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:FragmentActivity.java

示例8: createJavaFile

import java.io.PrintWriter; //导入方法依赖的package包/类
private FileObject createJavaFile (
        final FileObject root,
        final String pkg,
        final String name,
        final String content) throws IOException {
        final FileObject file = FileUtil.createData(
            root,
            String.format("%s/%s.java",
                FileObjects.convertPackage2Folder(pkg),
                name));
        final FileLock lck = file.lock();
        try {
            final PrintWriter out = new PrintWriter (new OutputStreamWriter(file.getOutputStream(lck)));
            try {
                out.print(content);
            } finally {
                out.close();
            }
        } finally {
            lck.releaseLock();
        }
        return file;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ClassIndexTest.java

示例9: doPost

import java.io.PrintWriter; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest request,
		HttpServletResponse response) throws ServletException, IOException {
	response.setContentType("application/json");
	response.setCharacterEncoding("utf-8");

	PrintWriter out = response.getWriter();

	String rawContent = IOUtils.toString(request.getReader());
	log.debug(String.format("request content: %s", rawContent));

	out.print(goodsDAO.findById(1));
}
 
开发者ID:MsBuggy,项目名称:AnyMall,代码行数:14,代码来源:GoodsCtrl.java

示例10: showConfigurations

import java.io.PrintWriter; //导入方法依赖的package包/类
private void showConfigurations ( final HttpServletResponse resp, final ConfigurationAdministrator admin, final String factoryId, final Configuration[] configurations ) throws IOException
{
    final PrintWriter stream = resp.getWriter ();
    stream.print ( "<table class='configuration' width='100%'>" );
    stream.print ( "<tr><th>ID</th><th>State</th><th>Error</th><th>Data</th></tr>" );

    Arrays.sort ( configurations, new Comparator<Configuration> () {

        @Override
        public int compare ( final Configuration o1, final Configuration o2 )
        {
            return o1.getId ().compareTo ( o2.getId () );
        }
    } );

    for ( final Configuration cfg : configurations )
    {
        stream.print ( "<tr>" );
        stream.print ( String.format ( "<td>%s</td>", cfg.getId () ) );
        stream.print ( String.format ( "<td>%s</td>", cfg.getState () ) );
        if ( cfg.getErrorInformation () != null )
        {
            stream.print ( String.format ( "<td>%s</td>", cfg.getErrorInformation ().getMessage () ) );
        }
        else
        {
            stream.print ( String.format ( "<td></td>" ) );
        }
        stream.print ( "<td><div style='float:right;'>" );

        showData ( stream, cfg.getData (), factoryId, cfg.getId () );

        stream.print ( "<form method='post'><input type='Submit' value='Delete' name='cmd_delete' /><input type='hidden' name='factoryId' value='" + factoryId + "' /><input type='hidden' name='configurationId' value=" + cfg.getId () + " /></form>" );
        stream.print ( "</div></td>" );

        stream.print ( "</tr>" );
    }

    stream.print ( "</table>" );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:41,代码来源:ListServlet.java

示例11: doGet

import java.io.PrintWriter; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws IOException, ServletException {
    PrintWriter out = res.getWriter();
    out.print("<p>" + getInitParameter("foo") + " "
            + getInitParameter("bar") + "</p>");
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:8,代码来源:DuplicateMappingParamServlet.java

示例12: dump

import java.io.PrintWriter; //导入方法依赖的package包/类
void dump(PrintWriter stream) {
  stream.print("[size=" + count);
  for (int i = 0; i < count; i++) {
    if (i != 0) {
      stream.print(", ");
      stream.print(timeStamps[i] - timeStamps[i - 1]);
    } else {
      stream.print(" " + timeStamps[i]);
    }
  }
  stream.println("]");
}
 
开发者ID:ampool,项目名称:monarch,代码行数:13,代码来源:StatArchiveReader.java

示例13: doGet

import java.io.PrintWriter; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");
    PrintWriter out = response.getWriter();

    // 调用service
    LoginService service = new LoginServiceImpl();
    MD5 md5 = new MD5();

    // 获得姓名
    String loginName = request.getParameter("loginName");
    String loginPwd = request.getParameter("loginPwd");  //转成MD5存储

    Login login;
    int check = -1;

    try {
        login = service.queryLogin(loginName);
        System.out.println(login);
        login.setLoginPwd(loginPwd);
        System.out.println(login);
        check = service.updateLogin(login);
        System.out.println(check);
        System.out.println(service.queryLogin(loginName));
    } catch (SQLException e) {
        e.printStackTrace();
    }
    Gson gson = new Gson();
    out.print(gson.toJson(check));
}
 
开发者ID:inkss,项目名称:hotelbook-JavaWeb,代码行数:31,代码来源:UpdatePwdServlet.java

示例14: handle

import java.io.PrintWriter; //导入方法依赖的package包/类
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException
{
    String scriptName = request.getPathInfo();
    scriptName = LocalUtil.replace(scriptName, testHandlerUrl, "");
    scriptName = LocalUtil.replace(scriptName, "/", "");

    String page = debugPageGenerator.generateTestPage(request.getContextPath() + request.getServletPath(), scriptName);

    response.setContentType(MimeConstants.MIME_HTML);
    PrintWriter out = response.getWriter();
    out.print(page);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:TestHandler.java

示例15: getFailureText

import java.io.PrintWriter; //导入方法依赖的package包/类
private static String getFailureText(final Object orig, final Object copy) {
    final StringWriter sw = new StringWriter();
    final PrintWriter pw = new PrintWriter(sw);

    pw.println("Test FAILED: Deserialized object is not equal to the original object");
    pw.print("\tOriginal: ");
    printObject(pw, orig).println();
    pw.print("\tCopy:     ");
    printObject(pw, copy).println();

    pw.close();
    return sw.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:SimpleSerialization.java


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