码迷,mamicode.com
首页 > 编程语言 > 详细

Java 应用

时间:2015-07-22 12:14:47      阅读:130      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!