首页 > 其他 > 详细

学习打卡第二天

时间:2019-03-21 23:58:36      阅读:323      评论:0      收藏:0      [点我收藏+]
 1 import java.io.IOException;
 2 
 3 public class IOTest {
 4 
 5     public static void main(String[] args) {
 6         byte[] buffer = new byte[1024];
 7         try 
 8         {
 9             int len = System.in.read(buffer);
10             String s = new String(buffer , 0 , len);
11             System.out.println("接收到了:"+len+"个字节");
12             System.out.println(s);
13             System.out.println("字符串长度为:"+s.length());
14         }catch(IOException e) 
15         {
16             
17         }
18         
19 
20     }
21 
22 }
 1 import java.io.BufferedInputStream;
 2 import java.io.BufferedOutputStream;
 3 import java.io.DataInputStream;
 4 import java.io.DataOutputStream;
 5 import java.io.FileInputStream;
 6 import java.io.FileNotFoundException;
 7 import java.io.FileOutputStream;
 8 import java.io.IOException;
 9 
10 public class IOTest1 {
11 
12     public static void main(String[] args) {
13         byte[] buffer = new byte[1024];
14         try {
15             DataOutputStream out = new DataOutputStream(
16                     new BufferedOutputStream(
17                             new FileOutputStream("a.dat")));
18             int i = 0xface;
19             out.writeInt(i);
20             out.close();
21             DataInputStream in = new DataInputStream(
22                     new BufferedInputStream(
23                             new FileInputStream("a.dat")));
24             int j = in.readInt();
25             System.out.println(j);
26         } catch (FileNotFoundException e) {
27             // TODO Auto-generated catch block
28             e.printStackTrace();
29         } catch (IOException e) 
30         {
31             // TODO Auto-generated catch block
32             e.printStackTrace();
33         }
34 
35     }
36 
37 }

以上是今天学习的io输入输出流,还有文件流,过滤器。

以下附今日学习异常捕捉截图:技术分享图片

学习打卡第二天

原文:https://www.cnblogs.com/sucker/p/10575617.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!