如题,各位帮帮忙,急用的

解决方案 »

  1.   

    import sun.net.*;
    import sun.net.ftp.*;class SFtpClient extends FtpClient
    {public boolean connect()

    try

    openServer(hostname,port);
       login(username,password); 
       binary(); 

    catch(FtpLoginException e)

    return false; 

    catch (IOException e)

    return false; 

    catch(SecurityException e) 

    return false; 


    return true;
    } public boolean getFormServer(String filename)
    {
    try
    {
    int ch;
    String filepath = tempDir + filename;
    File file = new File(filepath);
    RandomAccessFile getFile = new RandomAccessFile(file,"rw");
    getFile.seek(0);
    TelnetInputStream get = get(filename);
    DataInputStream put = new DataInputStream(get);

    while((ch=put.read()) >= 0)
    {
    getFile.write(ch);
    }

    put.close();
    get.close();
    getFile.close();

    return true;
    }
    catch(Exception e)
    {
    e.printStackTrace();
    return false;
    }
    }}