首页 > 编程语言 > 详细

Java 应用

时间:2015-07-22 12:12:58      阅读:133      评论:0      收藏:0      [点我收藏+]

I/O

System.out is a PrintStream object that outputs to the screen.

System.in is a InputStream object that reads from the keyboard.

InputStream objects (like System.in) read raw data from some source(e.g keyboard network), but don‘t format the data.

InputStreamReader objects compose the raw data into character (whick are typically two bytes long in Java)

BufferedReader objects compose the characters into entire lines of text.

import java.io.*;
class SimpleIO {
    public static void main(String[] arg) throws Exception {
        BufferedReader keybd =
            new BufferedReader(new InputStreamReader(System.in));
        System.out.println(keybd.readLine());
    }
}
import java.net.*;
import java.io.*;
class Netease {
    public static void main(String[] arg) throws Exception {
        URL u = new URL("http://www.163.com/");
        InputStream ins = u.openStream();
        InputStreamReader isr = new InputStreamReader(ins);
        BufferedReader whiteHouse = new BufferedReader(isr);
        System.out.println(whiteHouse.readLine());
    }
}

 

Java 应用

原文:http://www.cnblogs.com/whuyt/p/4666615.html

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