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"));