本帖最后由 bztf 于 2015-5-3 03:23 编辑
import java.net.*;
import java.io.*;
class Server
{
public static void main(String[] args)throws Exception
{
ServerSocket ss = new ServerSocket(14563);
Socket s = ss.accept();
//BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));//这些东西在浏览器中显示,也在控制台中显示
BufferedReader br = new BufferedReader(new FileReader("Server.java"));//这行代码为什么用浏览器打开啥都没有但是在控制台打印
PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
String temp = null;
while((temp = br.readLine())!=null)
{
System.out.println(temp);
pw.println(temp);
}
s.close();
ss.close();
}
} |
|