datainputstream
代码如下,请高手看看撒问题?
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
import org.omg.CORBA.DataInputStream;
public class ChatClient extends Frame {
Socket s=null;
DataOutputStream dao=null;
DataInputStream dis=null;
private boolean bconn=false;
TextField tfTxt = new TextField();
TextArea taContent = new TextArea();
public static void main(String[] args) {
new ChatClient().launchFrame();
}
public void launchFrame() {
this.setLocation(400, 300);
this.setSize(300, 300);
add(tfTxt, BorderLayout.SOUTH);
add(taContent, BorderLayout.NORTH);
pack();
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
disconnect();
System.exit(0);
}
});
tfTxt.addActionListener(new TFlistener());
this.setVisible(true);
connect();
}
public void connect(){
try {
s=new Socket("127.0.0.1",8888);
dao=new DataOutputStream(s.getOutputStream());
dis=new DataInputStream(s.getInputStream());System.out.println("connectd!");
bconn=true;
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void disconnect(){
try {
dao.close();
s.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private class TFlistener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String str = tfTxt.getText().trim();
taContent.setText(str);
tfTxt.setText("");
try {
dao.writeUTF(str);
dao.flush();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
红色部分报Cannot instantiate the type DataInputStream