MyEclipse消除warning重要么? 编程是MyEclipse总会出现warning,实际项目时允许出现么?还是要一个一个地优化,消灭warning? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 客户端import java.io.*;import java.net.*;import java.awt.*;import java.awt.event.*;class liaot extends Frame{ Socket socket=null; private TextArea text1; private TextField text2;//图形界面 liaot(){ text1 = new TextArea(); text2 = new TextField(); add(text1,"Center"); add(text2,"South"); try{ socket = new Socket("192.168.30.129",3334); }catch(Exception ee){} event(); setBounds(300,300,300,300); setVisible(true); }//事件响应 public void event(){ addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); text2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ // new Thread(new clientsend()).start(); new Thread(new clientrec()).start(); send(); //rece(); text2.setText(""); } }); } public static void main(String[] args)throws Exception { new liaot(); }//发送 public void send(){ byte[]buf = text2.getText().trim().getBytes(); String str = new String(buf,0,buf.length); System.out.println(str); // text1.setText(str+text2.getText()+"\r\n"); try{ DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); dos.writeUTF(str); dos.flush(); // out.write("\r\n".getBytes()); ; }catch(Exception e){} } class clientsend implements Runnable { public void run(){ send(); } }//接收 public void rece(){ try{ DataInputStream dis = new DataInputStream(socket.getInputStream()); String str = dis.readUTF(); text1.append(str+"\r\n"); }catch(Exception e){} } class clientrec implements Runnable { public void run(){ // byte[] buf = new byte[1024]; rece(); } } }服务端import java.io.*;import java.net.*;import java.util.*;class liaotserver { static List<server> list = new ArrayList<server>(); public static void main(String[] args)throws Exception { Socket socket; ServerSocket ss = new ServerSocket(3334); while(true){ socket = ss.accept();System.out.println("hahahah...."); server ser = new server(socket); list.add(ser); new Thread(ser).start(); } } static class server implements Runnable { private DataOutputStream dos; private DataInputStream dis; private Socket socket = null; server(Socket socket){ this.socket = socket; try{ dos = new DataOutputStream(socket.getOutputStream()); dis = new DataInputStream(socket.getInputStream()); }catch(Exception e){} } public void send(String str){ try{//System.out.println(str); dos.writeUTF(str); dos.flush(); }catch(Exception e){} } public void run(){ // byte[] buf = new byte[1024]; try{ while(true){ String str = dis.readUTF(); //System.out.println(str); for(int i=0;i<list.size();i++){ server s = list.get(i); s.send(str); } } }catch(Exception e){} } }}我运行一个客户端时,运行正常,显示结果正常,运行两个客户端时,我在第一个客户端写“你好”,第一个客户端能显示“你好”,但是第二个客户端不能显示,但是我要是在第二个客户端写上“哈哈”,”哈哈“不能显示,而是第一个客户端的”你好“显示出来了,每次输入都是这样,什么原因啊,怎么改? 对,让自己的代码完美,使其尽量不存在warning 怎么样不基于开发软件运行java? oracle数据库问题 除了sun以外,不同厂商实现的jdk/jre,有版本的说法么? String 转DTAE 问题 JAVA如何解析word编辑完成的.doc文档 JFreeChart 求助~ 各位帮忙进来看看,关于事件的问题?????????????????? poi导入导出问题。高人请进,散分了 帮我看看这个问题! 在英文NT下面,如何显示中文字符么? Integer ir=0626; 打印出406 难道是精度丢失? 如何把视频等多媒体信息存放在oracle中
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
class liaot extends Frame
{
Socket socket=null;
private TextArea text1;
private TextField text2;
//图形界面
liaot(){
text1 = new TextArea();
text2 = new TextField();
add(text1,"Center");
add(text2,"South");
try{
socket = new Socket("192.168.30.129",3334);
}catch(Exception ee){}
event();
setBounds(300,300,300,300);
setVisible(true);
}
//事件响应
public void event(){
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
text2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
// new Thread(new clientsend()).start();
new Thread(new clientrec()).start();
send();
//rece();
text2.setText("");
}
});
} public static void main(String[] args)throws Exception
{
new liaot();
}
//发送
public void send(){
byte[]buf = text2.getText().trim().getBytes();
String str = new String(buf,0,buf.length);
System.out.println(str);
// text1.setText(str+text2.getText()+"\r\n");
try{
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
dos.writeUTF(str);
dos.flush();
// out.write("\r\n".getBytes());
;
}catch(Exception e){}
}
class clientsend implements Runnable
{
public void run(){
send();
}
}
//接收
public void rece(){
try{
DataInputStream dis = new DataInputStream(socket.getInputStream());
String str = dis.readUTF();
text1.append(str+"\r\n");
}catch(Exception e){}
}
class clientrec implements Runnable
{
public void run(){
// byte[] buf = new byte[1024];
rece();
}
}
}
服务端
import java.io.*;
import java.net.*;
import java.util.*;
class liaotserver
{
static List<server> list = new ArrayList<server>();
public static void main(String[] args)throws Exception
{
Socket socket;
ServerSocket ss = new ServerSocket(3334);
while(true){
socket = ss.accept();
System.out.println("hahahah....");
server ser = new server(socket);
list.add(ser);
new Thread(ser).start();
}
}
static class server implements Runnable
{
private DataOutputStream dos;
private DataInputStream dis;
private Socket socket = null;
server(Socket socket){
this.socket = socket;
try{
dos = new DataOutputStream(socket.getOutputStream());
dis = new DataInputStream(socket.getInputStream());
}catch(Exception e){}
}
public void send(String str){
try{
//System.out.println(str);
dos.writeUTF(str);
dos.flush();
}catch(Exception e){}
}
public void run(){
// byte[] buf = new byte[1024];
try{
while(true){
String str = dis.readUTF();
//System.out.println(str);
for(int i=0;i<list.size();i++){
server s = list.get(i);
s.send(str);
}
}
}catch(Exception e){}
}
}}
我运行一个客户端时,运行正常,显示结果正常,运行两个客户端时,我在第一个客户端写“你好”,第一个客户端能显示“你好”,但是第二个客户端不能显示,但是我要是在第二个客户端写上“哈哈”,”哈哈“不能显示,而是第一个客户端的”你好“显示出来了,每次输入都是这样,什么原因啊,怎么改?