Java随机数0到99_⽤JAVA写⼀段随机⽣成10到99的程序。.. package com.zpj.socket;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.ServerSocket;
import java.Socket;
import com.zpj.util.NetUtil;
public class Server {
public static void main(String[] args) {
ServerSocket serverSocket = null;
Socket server = null;
BufferedReader readFromClinet = null;
BufferedWriter writeToClinet = null;
BufferedReader readFromSys = null;
try {
//set server point
serverSocket = new ServerSocket(8888);
System.out.println("服务器等待连接.......");
server = serverSocket.accept();
System.out.println("服务器连接成功.......");
/
/new read message from clinet object
readFromClinet = new BufferedReader(new InputStream()));
//read message
System.out.adLine());
//new write message to clinet object
writeToClinet = new BufferedWriter(new OutputStream()));
//new object read message from system
readFromSys = new BufferedReader(new InputStreamReader(System.in));
//set message information
String message = adLine();
//wirte message to clinet
writeToClinet.write("server say :"+message+"\n");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
java生成随机数的方法
NetUtil.closeAll(readFromSys,writeToClinet,readFromClinet,server,serverSocket);
}
}
}
糟糕了 输⼊不了 了 。。。你参考下。。看看有没有啥作⽤
客户端核⼼代码
writerToServer = new BufferedWriter(new OutputStream())); int i = (int)(Math.random()*89+10);
writerToServer.write("clinet say :"+i+"\n");
writerToServer.flush();
⼤概就这样吧

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。