myserver.java
来自「用jsp做的能够实现简单的短信息发送回复的短消息系统」· Java 代码 · 共 61 行
JAVA
61 行
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 + =
减小字号Ctrl + -
显示快捷键?