Java Socket通信讀取有不少需要我們注意的知識點當我們在使用的時候有很多的問題擺在我們面前下面我們就來詳細的學習有關Java <> Socket通信讀取的相關代碼編寫
以下是Java Socket通信讀取的相關代碼
import javaioBufferedReader;
import javaioBufferedWriter;
import javaioFile;
import javaioFileWriter;
import javaioInputStreamReader;
import URL;public class URLReader {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// 聲明拋出所有例外
URL tirc = new URL();
File writeFile = new File(d:\\l);
// 構建一URL對象
BufferedReader in = new BufferedReader(new InputStreamReader(tircopenStream()));
BufferedWriter bos = new BufferedWriter(new FileWriter(writeFile));
//byte[] b=new byte[];
String inputLine;
// 使用openStream得到一輸入流並由此構造一個BufferedReader對象
while ((ininputLine = inreadLine()) != null){
boswrite(inputLine);
Systemoutprintln(inputLine);
}
bosflush();
inclose();
bosclose();
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26861.html