|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
关于第二点:俺问问你,如果是企业级项目的话,诸如RMI,EJB,等一些关键技术,这些难道都不需要学么?如果光是使用jsp,servlet,javabean的话。收集//tcpServer.javabyfpont3/2000
//usage:javatcpServer<portnumber>.
//defaultportis1500.
//connectiontobeclosedbyclient.
//thisserverhandlesonly1connection.
importjava.net.*;
importjava.io.*;
publicclasstcpServer{
publicstaticvoidmain(Stringargs[]){
intport;
ServerSocketserver_socket;
BufferedReaderinput;
try{
port=Integer.parseInt(args[0]);
}
catch(Exceptione){
System.out.println("port=1500(default)");
port=1500;
}
try{
server_socket=newServerSocket(port);
System.out.println("Serverwaitingforclientonport"+
server_socket.getLocalPort());
//serverinfiniteloop
while(true){
Socketsocket=server_socket.accept();
System.out.println("Newconnectionaccepted"+
socket.getInetAddress()+
":"+socket.getPort());
input=newBufferedReader(newInputStreamReader(socket.getInputStream()));
//printreceiveddata
try{
while(true){
Stringmessage=input.readLine();
if(message==null)break;
System.out.println(message);
}
}
catch(IOExceptione){
System.out.println(e);
}
//connectionclosedbyclient
try{
socket.close();
System.out.println("Connectionclosedbyclient");
}
catch(IOExceptione){
System.out.println(e);
}
}
}
catch(IOExceptione){
System.out.println(e);
}
}
}
//tcpClient.javabyfpont3/2000
//usage:javatcpClient<server><port>
//defaultportis1500
importjava.net.*;
importjava.io.*;
publicclasstcpClient{
publicstaticvoidmain(String[]args){
intport=1500;
Stringserver="localhost";
Socketsocket=null;
StringlineToBeSent;
BufferedReaderinput;
PrintWriteroutput;
intERROR=1;
//readarguments
if(args.length==2){
server=args[0];
try{
port=Integer.parseInt(args[1]);
}
catch(Exceptione){
System.out.println("serverport=1000(default)");
port=1500;
}
}
//connecttoserver
try{
socket=newSocket(server,port);
System.out.println("Connectedwithserver"+
socket.getInetAddress()+
":"+socket.getPort());
}
catch(UnknownHostExceptione){
System.out.println(e);
System.exit(ERROR);
}
catch(IOExceptione){
System.out.println(e);
System.exit(ERROR);
}
try{
input=newBufferedReader(newInputStreamReader(System.in));
output=newPrintWriter(socket.getOutputStream(),true);
//getuserinputandtransmitittoserver
while(true){
lineToBeSent=input.readLine();
//stopifinputlineis"."
if(lineToBeSent.equals("."))break;
output.println(lineToBeSent);
}
}
catch(IOExceptione){
System.out.println(e);
}
try{
socket.close();
}
catch(IOExceptione){
System.out.println(e);
}
}
}
但是我同意你的观点,对于大型项目来说,应该是采用框架的一部分,根据功能的不同而改进,欢迎你能再提出些宝贵意见,我会多多学习的。说到jbuilder,我可能是个人感觉,用的时候确实没有vs爽,我最喜欢的IDE是netbeans,谢谢。 |
|