对于此代码,可执行jar文件未创建原因? [英] For this code executable jar file is not created why this happens ?

查看:66
本文介绍了对于此代码,可执行jar文件未创建原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import java.net.*; 
import java.io.*; 
public class Server 
{ 
    public static void main (String [] args ) throws IOException 
    { 
    int filesize=1022386; 
    int bytesRead; int currentTot = 0; 
      try
    {  
    ServerSocket serverSocket = new ServerSocket(9999); 
    Socket socket = serverSocket.accept(); 
    System.out.println("Accepted connection : " + socket);
    BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));    
    String temp=br.readLine();
    System.out.println("The mesage from client is::"+temp);
    PrintStream  pr=new PrintStream(socket.getOutputStream()); 
                String  str = "acknowledgement from server";
                pr.println(str);
             
    byte [] bytearray = new byte [filesize]; 
    InputStream is = socket.getInputStream(); 
    FileOutputStream fos = new FileOutputStream("d:/here/sreethu.doc"); 
    BufferedOutputStream bos = new BufferedOutputStream(fos); 
    bytesRead = is.read(bytearray,0,bytearray.length); 
    currentTot = bytesRead; 
    
    do 
    { 
        bytesRead = is.read(bytearray, currentTot, (bytearray.length-currentTot)); 
        if(bytesRead >= 0) 
        currentTot += bytesRead; 
    } 
            while(bytesRead > -1); bos.write(bytearray, 0 , currentTot); 
            bos.flush(); bos.close(); socket.close();
    }
    catch(Exception ex)
        
    {
        
    }
    }
}

推荐答案

try{
  // fancycoding
}

catch(Exception ex)
        
{
    ??? WHY EMPTY ???
    ex.printStackTrace(); // this should be in there to see what is wrong (unless you have a proper logging, then the exception should be listed there)
}


这篇关于对于此代码,可执行jar文件未创建原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆