?? myserver.java
字號:
import java.io.*;
import java.net.*;
public class MyServer
{
public static void main(String[]args) throws IOException
{
String str = new String();
char str1[] = new char[1024];
ServerSocket server=new ServerSocket(8005);
System.out.println("你好我是張明socket");
Socket client = server.accept();
System.out.println("你好我是張明");
try
{
int streamlong = client.getReceiveBufferSize();
System.out.println("you stream long is "+streamlong);
BufferedReader in=new BufferedReader (new InputStreamReader (client.getInputStream()));
System.out.println("you come reader");
PrintWriter out=new PrintWriter(client.getOutputStream());
System.out.println("Hello ");
in.mark(streamlong);
in.reset();
if ( in.ready())
{
str = in.readLine();
//out.writeUTF("hasrecevi ");
System.out.println(str);
}
else
{
System.out.println("stream is not ready ");
}
}
catch(IOException ioe )
{
System.out.println(ioe.getMessage());
}
//System.out.println("Hello ni hao ");
finally
{
System.out.println(str);
}
//out.println("hasreceive....");
//out.flush();
//if(str.equals("end"))
client.close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -