Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

1.6. Network

Java 网络相关操作

1.6.1. URL

		
import java.net.*;
import java.io.*;

public class URLReader {
    public static void main(String[] args) throws Exception {

        URL url = new URL("http://www.netkiller.cn/");
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

        String inputLine;
        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);
        in.close();
    }
}
		
		

1.6.2. java.io.tmpdir

改变java.io.tmpdir的默认值

System.setProperty("java.io.tmpdir", "/vat/tmp");
System.out.println(System.getProperty("java.io.tmpdir"));