- 浏览: 47136 次
文章分类
最新评论
这两个函数一个是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个状态,计算机里用字节来作为最基本的存储单位。一般来说,英文状态下一个字母或数字(称之为字符)占用一个字节,一个汉字用两个字节表示。在不同的编码方式下一个字符占的字节数不太一样。
简单的来说:字节组成字符
http://blog.chinaunix.net/uid-26359455-id-3130555.html
//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个状态,计算机里用字节来作为最基本的存储单位。一般来说,英文状态下一个字母或数字(称之为字符)占用一个字节,一个汉字用两个字节表示。在不同的编码方式下一个字符占的字节数不太一样。
简单的来说:字节组成字符
http://blog.chinaunix.net/uid-26359455-id-3130555.html
发表评论
-
全角半角混在截取固定位数
2015-08-27 18:29 720package zkktest; import java ... -
java读写txt文件
2015-04-22 11:06 648import java.io.BufferedReader; ... -
struts2前后台传值汇总-(4)ServletRequestAware-http格式
2015-03-13 22:20 755后台调用ServletRequestAwa ... -
struts2前后台传值汇总-(3)ServletActionContext-http格式
2015-03-13 22:08 704后台调用ServletActionContext.getS ... -
struts2前后台传值汇总-(2)RequestAware-map格式
2015-03-13 21:51 1392后台继承RequestAware,SessionAware ... -
struts2前后台传值汇总-(1)ActionContext-map格式
2015-03-13 21:38 1197后台调用ActionContext中的getObject( ... -
复制新项目注意事项
2015-02-25 22:24 708当你从别的项目复制为一个新项目的时候,需要.修改Web p ... -
用java进行文件转码方法
2015-01-30 16:01 916用java进行文件转码方法 BufferedReader ... -
java文件转码方法
2015-01-30 16:01 1BufferedReader br = new Buffer ... -
导zip4j_1.3.2.jar包,出力压缩加密csv文件
2015-01-21 11:49 792导包 入口 public static ... -
不导包,压缩出力csv文件
2015-01-21 11:38 1001最近研究压缩csv文件出力,根据网上资料,整理了一套用不导 ... -
学习:java设计模式—工厂模式
2015-01-09 19:01 570一、工厂模式主要是 ... -
Eclipse CVS更换帐号的方法
2014-08-18 11:43 676使用CVS进行版本控制,当要提交一个文件时,发现需要重新输入C ... -
BigDecimal属性
2014-04-23 09:56 821BigDecimal abs() ... -
BigDecimal对象的用法(加减乘除 + 四舍五入)
2014-04-21 11:10 815java.math.BigDecimal。BigDecimal ... -
简单的ArrayList去重
2014-04-10 09:18 691public static void main(String[ ... -
正则表达式使用
2014-03-20 11:19 565java.lang包中的String类,java.util.r ... -
Java中throw和throws的区别
2014-02-06 15:45 444系统自动抛出的异常 所有系统定义的编译和运行异常都可以由系统自 ... -
全角半角转换问题
2013-12-05 13:17 1126网上找个日文全角半角转换的方法。整理如下: public c ...
相关推荐
主要介绍了 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("表单参数名:" + item.getFieldName() + ",表单参数值:" + item.getString("UTF-8"));} else {System.out.println("上传文件的大小:" + item.getSize()); System.out.println("上传文件的类型:...
System.out.println("《辽宁日报》今日报道,6月3日辽宁召开省委常委扩大会,会议从下午两点半开到六点半,主要议题为:落实中央巡视整改要求。"); for(int i = 0; i < unit.length; i ){ 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("在线用户: "+"人数: "+...