通过http协议的话可以使用URL,不然就只有SOCKET一条路啦!

解决方案 »

  1.   

    使用sun.net.ftp.*包可以把,谁知道怎么用??有例子吗
      

  2.   

    曾用com.jscape.inet.*可以做到,例如取文件http://202.202.202.202/aa.jpgJHTTP http = new JHTTP();
    http.setURL("http://202.202.202.202/aa.jpg");
    //http11.addParameter("type","S"); 如有参数
    byte[] aa = http.getContents();试下,我也不知道行不行。
      

  3.   

    public boolean connect() 
    {
    int iReplyCode = 0;
    boolean bLoginOK = false; // Check whether the parameters are all valid
    if( m_strServer == null || m_strServer.equals("") ||
    m_iPort <= 0 ||
    m_strUserName == null ||
    m_strPassword == null)
    {
    return false;
    } try
    {
    m_ftpClient = new FTPClient();

    // Connect server
    m_ftpClient.connect(m_strServer, m_iPort); // Get the reply code and check whether the connection is successful
    iReplyCode = m_ftpClient.getReplyCode();
    if(FTPReply.isPositiveCompletion(iReplyCode) == false) // Connect failed
    {
    disconnect();

    return false;
    } // Login
    bLoginOK = m_ftpClient.login(m_strUserName, m_strPassword);

    }
    catch(IOException IOe)
    {
    disconnect();

    bLoginOK = false;
    }

    return bLoginOK;
    }
      

  4.   

    public boolean setCurrentDir(String strPath) 
    {
    if(m_ftpClient == null || !m_ftpClient.isConnected())
    {
    return false;
    } try
    {
    // Change the current work path
    m_ftpClient.changeWorkingDirectory(strPath);
    }
    catch(IOException IOe)
    {
    disconnect();

    return false;
    }

    return true;
    }
      

  5.   

    public boolean getFile(String strDestFile) 
    {
    BufferedOutputStream buffOutputStream = null; if( m_ftpClient == null || !m_ftpClient.isConnected() || 
    m_strRemoteDir == null || m_strRemoteDir.equals("") ||
    m_strRemoteFile == null || m_strRemoteFile.equals(""))
    {
    return false;
    }

    try
    {
    // Create output stream
    buffOutputStream = new BufferedOutputStream(new FileOutputStream(strDestFile));
    }
    }
    catch(FileNotFoundException FNFe)
    {
    return false;
    } // Set remote work path
    setCurrentDir(m_strRemoteDir); try
    {
    // Get remote file data
    if(m_ftpClient.retrieveFile(m_strRemoteFile, buffOutputStream) == false)
    {
    return false;
    } // put the file data into local file
    buffOutputStream.flush();
    buffOutputStream.close();
    }
    catch(IOException IOe)
    {
    return false;
    }

    return true;
    }