- 浏览: 305335 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
liuyong19832011:
,赞一个
Java通过BufferedWriter追加内容到文件末尾的几种常用方法 -
justjavac:
总结很好,怎么没人支持呢?最近发现iteye踩贴现象很严重。
shell数组的使用
[转] System.out.println()和System.out.write()的区别
- 博客分类:
- JAVA
转至:http://blog.chinaunix.net/uid-26359455-id-3130555.html
这两个函数一个是System.out.write()输出字符流,System.out.println()是输出字节流,很简单。看下面这个程序就明白了。
结果:
A
65
测试2:
这两句的效果是一样的。
什么是字符,什么是字节?
1个字节等于8个bit位,每个bit位又0/1两种状态也就是说一个字节可以表示256个状态,计算机里用字节来作为最基本的存储单位。一般来说,英文状态下一个字母或数字(称之为字符)占用一个字节,一个汉字用两个字节表示。在不同的编码方式下一个字符占的字节数不太一样。
简单的来说:字节组成字符
这两个函数一个是System.out.write()输出字符流,System.out.println()是输出字节流,很简单。看下面这个程序就明白了。
//import java.util.*; public class Test { public static void main(String[] args){ // Scanner in = new Scanner(System.in); int a = 65; System.out.write(a); System.out.println("\n"); System.out.println(a); } }
结果:
A
65
测试2:
import java.io.IOException; public class Test2 { public static void main(String[] args) throws IOException{ System.out.write("hello\n".getBytes()); System.out.println("hello"); } }
这两句的效果是一样的。
什么是字符,什么是字节?
1个字节等于8个bit位,每个bit位又0/1两种状态也就是说一个字节可以表示256个状态,计算机里用字节来作为最基本的存储单位。一般来说,英文状态下一个字母或数字(称之为字符)占用一个字节,一个汉字用两个字节表示。在不同的编码方式下一个字符占的字节数不太一样。
简单的来说:字节组成字符
发表评论
-
[转]Java读取解析sql文件,并使用netiler dao执行sql
2013-12-26 15:25 7991转至: 最近在做系统数据初始化,采用sql形式导入基础数据,这 ... -
[转]Java 单例模式详解
2013-08-20 11:15 795转至:http://www.cnblogs.com/whgw/ ... -
[转]Java synchronized详解
2013-08-07 19:12 856转至:http://www.cnblogs.com/devin ... -
[转]Java Socket Programming-Transferring large sized files through socket
2013-08-06 18:26 2871转至:http://www.coderpanda.com/ja ... -
【转】java如何从ftp下载超大文件
2013-08-06 00:28 2051转至: http://www.2cto.com/k ... -
【转】java大数据处理(千万级别FTP下载)
2013-08-06 00:20 1532转至:http://www.th7.cn/Program/ja ... -
Jakarta-Common-IO使用笔记
2013-08-05 14:11 1023转至: http://tech.ddvip.com/2008- ... -
[转]StringUtils详细介绍
2013-07-24 17:31 1299原文地址:http://www.blogj ... -
[转]BeanUtils.copyProperties()的用法
2013-07-24 15:16 2692原文地址: http://blog.csdn.net/itmy ... -
[转]Java内存泄漏
2013-04-10 13:45 875http://www.cnblogs.com/dotnetdo ... -
【转】java实现导出Excel文件和XML文件
2013-03-07 23:00 1403http://www.2cto.com/kf/201208/1 ... -
Java中split的注意事项
2013-01-22 00:08 1058stringObj.split([separator,[lim ... -
Struts2.2.1注解方式使用json整合jquery getJson方法
2013-01-10 22:53 01.引入与json相关的jar文件: json-lib ... -
ssh2常用annotation
2012-01-30 21:54 1005Spring annotation: @Servic ... -
Java日期类型与String的转换
2011-11-04 14:30 91521.String转Date SimpleDateFormat ... -
Java调用批处理或可执行文件[转载]
2011-07-22 17:17 756http://www.blogjava.net/supercr ... -
Java通过BufferedWriter追加内容到文件末尾的几种常用方法
2011-07-18 16:15 33837import java.io.BufferedWriter; ... -
JAVA map的遍历
2011-07-05 09:07 1021第一种entrySet,效率较高,推荐用这种: Map ... -
java.lang.OutOfMemoryError: Java heap space 的解决[转载]
2011-05-27 14:00 10461、首先是:java.lang.OutOfMemoryErro ... -
synchronized与static synchronized 的区别
2011-02-22 14:37 29071.synchronized与static synchro ...
相关推荐
主要介绍了 java 中 System.out.println()和System.out.write()的区别.的相关资料,需要的朋友可以参考下
System.out.println("--下载路径--:"+path); System.out.println("----"); System.out.println("--------"); //sPath = HttpRequest.forwardIn(restTemplate,"http://common-method/","getFileUrl",obj); ...
System.out.println("disconnect success"); } catch (IOException ex) { System.out.println("not disconnect"); System.out.println(ex); } } public void upload() { //this....
System.out.println("********************************************"); result+="********************************************"+"\n"; /* IP数据报报文头 */ byte[] l = packet.header; String str = ...
System.out.println(result.size());; System.out.println(result); } /** * 列出基础字符串(base)的所有组合 * @param base 以该字符串作为基础字符串,进行选择性组合。 * @param buff 所求字符串的...
System.out.println("current record: " + cr.getCurrentRecord()); // 本行内容 System.out.println("RawRecord:" + cr.getRawRecord()); // 每一列的内容 System.out.println("getValues() ");...
System.out.println("proxy server OK"); while (true) { Socket s=ss.accept(); process p=new process(s); Thread t=new Thread(p); t.start(); } } catch (Exception e) { System.out.println(e); } ...
System.out.println(s); File file = new File(s); String name = file.getName(); try { socket = new Socket("192.168.1.5",10000); } catch (IOException e) { e.printStackTrace(); ...
System.out.println("是否可写:"+f.canWrite()); System.out.println("是否是隐藏:"+f.isHidden()); System.out.println("文件的绝对路径:"+f.getAbsolutePath()); System.out.println("获得文件名:"+f....
System.out.println("《辽宁日报》今日报道,6月3日辽宁召开省委常委扩大会,会议从下午两点半开到六点半,主要议题为:落实中央巡视整改要求。"); for(int i = 0; i < unit.length; i ){ System.out.println...
System.out.println("表单参数名:" + item.getFieldName() + ",表单参数值:" + item.getString("UTF-8"));} else {System.out.println("上传文件的大小:" + item.getSize()); System.out.println("上传文件的类型:...
/** * 用缓存的字节入做写入操作 ...// System.out.println("bs=="+bs.toString().trim()); } catch (IOException e) { e.printStackTrace(); } System.out.println("each="+each); }
System.out.println(ex.getMessage()); } } } /* * 使用org.apache.strtus.upload.FormFile实现文件的单一上传 */ private void singleUploadFile(IndexActionForm objForm) { if(objForm....
System.out.println("start server at port " port); //在命令窗口输出提示信息 while (true){ //一直等待客户端连接 Socket client=serverSocket.accept(); //等待连接 System.out.println("Connect: " ...
System.out.println("开始读取"); FileReader fr = new FileReader("E://change.txt");//需要读取的文件路径 BufferedReader br= new BufferedReader(fr); String s = br.readLine(); while(s!=null)//如果...
System.out.println("文件长度:"+(int)file.length()); s=ss.accept(); System.out.println("建立socket连接"); DataInputStream dis=new DataInputStream(new BufferedInputStream(new ...
System.out.println(System.getProperty("user.dir"));//输出当前的项目存放的路径 String uploadPath=req.getSession().getServletContext().getRealPath("/upload"); System.out.println(uploadPath);//输出...
System.out.println("九九乘法表写入文件成功 ..."); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { fos.close()...
System.out.println("start server at port " port); //在命令窗口输出提示信息 while (true){ //一直等待客户端连接 Socket client=serverSocket.accept(); //等待连接 System.out.println(...
}catch(IOException ee){System.out.println("无法关闭");} } setTitle("用户"+name+"离线"); textPanel.send.setEnabled(false); nameList.removeAll(); nameLable.setText("在线用户: "+"人数: "+...