大多数操作系统都有三个标准文件描述符:标准输入,标准输出,标准出错。
三个操作系统的文件描述符映射到编程语言的标准库中,往往加了一层包装,但是名字通常还是叫标准输入,标准输出,标准出错。
在其它语言中的一般写法是:stdin,stdout,stderr(有的语言里大写,有的语言里小写)。对应Java中的System.in,System.out,System.err。
在语言层面的实现三个文件描述符都是可以重定向的(只要你想)。但是一般而言,如果你在unix shell或windows command line中使用管道或重定向,则只是针对标准输入和输出。
另外,标准输出和标准出错的一个区别是,标准输出往往是带缓存的,而标准出错没有缓存(默认设置,可以改)。所以如果你用标准出错打印出来的东西可以马上显示在屏幕,而标准输出打印出来的东西可能要再积累几个字符才能一起打印出来。如果你在应用中混用标准输出和标准出错就可能看到这个问题。
我的表达能力有限。总的来说,System.out用于正常的输出,也就是程序真正想输出的内容。而System.err用于出错信息的输出,也就是你本来不期待看到的东西。
<!--End_rbody_39615631//--> |
相关推荐
下面小编就为大家带来一篇java基础(System.err和System.out)详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
System.err.println("私钥签名——公钥验证签名"); // 产生签名 String sign = CertificateUtils.signToBase64(data.getBytes("utf-8"), keyStorePath, alias, password); System.out.println("私钥签名:" + ...
System.out.println(rs.getString(1)); else System.out.println("totle:0"); rs.close(); stmt.close(); conn.close(); } catch (ClassNotFoundException cnfe) { System.err.println("Unable to...
System.out.println("结果:" + resultEntity.getResult() + "|状态:" + resultEntity.getStatusCode()); } else { System.err.println("执行出错了-->" + resultEntity.getErrorMsg()); } } else ...
System.err.println("IOException: " + ioe); } } /* 通过建立的连接请求一个页面,显示回应然后关闭socket */ public static void getPage(Socket clientSocket) { try { // 需要输入和输出流
反射机制用Java描述下载资料 import java.lang.reflect.Array; public class ArrayTest { public static void main(String[] args){ try{ //创建一个元素类型为String,长度为... System.err.println(e); }
// 文件名:moreServer.java import java.io.*; import java.net.*; import java.util.*; /** * <p>Title: 多线程服务器 * <p>Description: 本实例使用多线程实现... System.out.println("close err"+e); } } } }
import java.util.ArrayList; import java.util.List; ... MongoCredential credential = MongoCredential.createScramSha... System.err.println( e.getClass().getName() + ": " + e.getMessage() ); } } }
System.err.println(str1 == str2); A.True B. false 2、下面程序的运行结果:() public static void main(String args[]) { Thread t = new Thread() { public void run() { pong(); } }; t.run(); ...
System.out.print ——标准输出流 Java 的流类,主要是:输入流类 InputStream 输出流类 OutputStream Java 系统预先定义好 3 个流对象,静态属性 System.out 标准输出设备:显示器 ...
System.out和System.err都被打印到catalina.out。catalina.out不会rotate。一般在部署Tomcat后,运行久了,catalina.out文件会越来越大,对系统的稳定造成了一定的影响。 1、可通过修改conf/logging.properties日志...
System.err.println("Wrong hex ley lenght (" + line.length() + "/" + keyLen/4 + ")"); // make binary key if (ishex) bin = hextobin(line); else bin = asciitobin(line); ...
System.err.println("保存私钥到: privateKey.dat"); //从文件中得到公钥编码的字节数组 FileInputStream fin = new FileInputStream("publicKey.dat"); //打天publicKey.dat ByteArrayOutputStream ...
The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the...
System.out.println("---------------"+" "+"----------------"); while (rs.next()) { String s = rs.getString("sitename"); String f = rs.getString("siteurl"); //取得数据库中的数据 System.out.println...
System.out和System.err都被打印到catalina.out。catalina.out不会rotate。一般在部署Tomcat后,运行久了,catalina.out文件会越来越大,对系统的稳定造成了一定的影响。 1、可通过修改conf/logging.properties日志...
System.err.println("Usage:java MessageDigestExample text"); System.exit(1); } byte[] plainText=args[0].getBytes("UTF8"); //使用getInstance("算法")来获得消息摘要,这里使用SHA-1的160位算法 ...
由来编码中我们常常需要调试输出一些信息,除了打印日志,最长用的要数System.out和System.err比如我们打印一个Hello World,可以这样写:
System.err.println("请求出错: "+ getMethod.getStatusLine()); } /* 5 处理 HTTP 响应内容 */ // HTTP响应头部信息,这里简单打印 Header[] headers = getMethod.getResponseHeaders(); for (Header h : ...
System.err.println("Exception when close a connection: " + ex.getMessage()); } } /** * Close all resources created by this class. */ public void closeAllResources() { for (int i = 0; i ...