Logo Search packages:      
Sourcecode: jftp version File versions  Download package

void net::sf::jftp::net::FtpConnection::list (  )  throws IOException [inline]

List remote directory. Note that you have to get the output using the sort*-methods.

Parameters:
outfile The file to save the output to, usually Settings.ls_out

Implements net::sf::jftp::net::BasicConnection.

Definition at line 2305 of file FtpConnection.java.

References ascii(), net::sf::jftp::net::DataConnection::getInputStream(), getLine(), net::sf::jftp::net::JConnection::getReader(), getTypeNow(), host, jcon, modeStream(), pause(), net::sf::jftp::net::JConnection::send(), and type().

Referenced by cleanDir(), exists(), and rawUpload().

    {
        String oldType = ""; 

        try
        {
            BufferedReader in = jcon.getReader();

            int p = 0;

            modeStream();

            oldType = getTypeNow();
            ascii();

            p = negotiatePort();
            dcon = new DataConnection(this, p, host, null, DataConnection.GET, false, true); //,null);

            while(dcon.getInputStream() == null)
            {
                  //System.out.print("#");
                pause(10);
            }
            DataInputStream input = new DataInputStream(dcon.getInputStream());
            
            jcon.send(LIST);

            
            String line;
            currentListing.removeAllElements();
            
            while((line = input.readLine()) != null) {
                  System.out.println("-> "+line);
                  if(!line.trim().equals("")) { 
                        currentListing.add(line);
                  }
            }
            
            getLine(POSITIVE); //FTP226_CLOSING_DATA_REQUEST_SUCCESSFUL);
            input.close();

            if(!oldType.equals(ASCII))
            {
                type(oldType);
            }
        }
        catch(Exception ex)
        {
            Log.debug("Cannot list remote directory!");

            if(!oldType.equals(ASCII))
            {
                type(oldType);
            }

            ex.printStackTrace();
            throw new IOException(ex.getMessage());
        }
    }


Generated by  Doxygen 1.6.0   Back to index