本帖最后由 petrel0425 于 2011-08-18 15:35:26 编辑

解决方案 »

  1.   

    可以考虑一下 commons-ftp,有相应的包。
      

  2.   

    HttpURLConnection 打开ftp的url,直接下载文件就可以了。
      

  3.   


    private static String getStaticPage(String surl) {
            String htmlContent = "";
            try {
                java.io.InputStream inputStream;
                java.net.URL url = new java.net.URL(surl);
                java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url
                        .openConnection();
                connection.connect();
                inputStream = connection.getInputStream();
                byte[] bytes = new byte[1024 * 2000];
                int index = 0;
                int count = inputStream.read(bytes, index, 1024 * 2000);
                while (count != -1) {
                    index += count;
                    count = inputStream.read(bytes, index, 1);
                }
                htmlContent = new String(bytes, "UTF-8");
                connection.disconnect();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return htmlContent.trim();
        }    public static void main(String[] args) {
            try {
                String src = getStaticPage("http://www.google.com");
                File file = new File("d:\\aa.html");
                FileWriter resultFile = new FileWriter(file);
                PrintWriter myFile = new PrintWriter(resultFile);// 写文件
                myFile.println(src);
                resultFile.close();
                myFile.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
      

  4.   

    commons-net-3.0.1 可以用这个,官方也有样例。