📄 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 + -