本人初学Java,希望大家提供下源码,及我应该学习的有关FTP资料,或者有用Java编写FTP简单服务器的流程图(中文版)。
谢谢,本人邮箱[email protected]
个人感觉编写该程序应该需要Java的网络编程,线程,流,套接字的知识
因未找到详细介绍有关FTP编写的方法,故发此贴,希望大家多多指教!

解决方案 »

  1.   

    给你发了一个,早期收藏的PUDN上的别人的一个作品。代码标记的很详细,有一定的学习价值。
      

  2.   

    我没有,不过友情up下啦,建议在csdn上面的下载专区去找,搜索ftp应该可以找到很多的啦!
      

  3.   


    public void doGet(HttpServletRequest req, HttpServletResponse res)   throws ServletException, IOException {
    String servlet_name="/servlets/data/";
            
            String downloadfilepath=svrinfo_u.get_info().getProperty("downloadfilepath");
           
            //get the file path by the method of the "replaceAll"
    String filePath=req.getRequestURI().replaceAll(servlet_name, downloadfilepath);

    String[][] fileNTD = null;

    File file = new File(filePath);

    if(file.isFile()){
    //start the doDownload
    doDownload(req,res,filePath);

    }else{
    //list the file
    fileNTD=readFolderByFile(filePath);

    }

    }
            




    }



    private void doDownload(HttpServletRequest req, HttpServletResponse res,String downloadfilepath) throws IOException{


     String cacheTime="0";

     File file = new File(downloadfilepath);

     res.setHeader("Location",downloadfilepath);
     
     res.setHeader("Cache-Control", "max-age=" + cacheTime);
     
     res.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
     
     OutputStream outputStream = res.getOutputStream();
     
     InputStream  inputStream  = new FileInputStream(downloadfilepath);
     
     
     
     byte[] buffer = new byte[1024];
     
     int i = -1;
     
     while ((i = inputStream.read(buffer)) != -1) {
     
     outputStream.write(buffer, 0, i);
      
      }
     
     outputStream.flush();
     
     outputStream.close();
     
     inputStream.close();
     
     outputStream = null;






    }
      

  4.   

    麻烦,给我发一份FTP的程序
      

  5.   

    给我发一份,用java编写的一个FTP客户端,[email protected]