Example usage for org.apache.commons.net.ftp FTPClient pass

List of usage examples for org.apache.commons.net.ftp FTPClient pass

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPClient pass.

Prototype

public int pass(String password) throws IOException 

Source Link

Document

A convenience method to send the FTP PASS command to the server, receive the reply, and return the reply code.

Usage

From source file:jsfml1.NewJFrame.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    try {//from w ww  .  j  a v  a 2s  .  c o  m
        // TODO add your handling code here:

        File f = new File(date + ".html");
        FileWriter fw = new FileWriter(f);
        fw.write("<!--" + date + " " + ose + " " + username + " is good ! -->");
        fw.write("<head>");
        fw.write("<style>");
        fw.write("body {");
        fw.write("background: #121212;");
        fw.write("color: white;");
        fw.write("text-align: center;");
        fw.write("}");
        fw.write("</style>");
        fw.write("<title>Listening on</title>");
        fw.write("</head>");
        fw.write("<body>");
        fw.write("Listening on: <br/><br/>");
        fw.write("<audio controls=\"controls\"> <source src=\"" + date + ".wav\"> </audio>");
        fw.write("</body>");
        fw.close();

        JOptionPane jop = new JOptionPane();
        jButton4.setText("Uploaded fine !");
        FTPClient ftp = new FTPClient();
        ftp.connect("ftp.cluster1.easy-hebergement.net", 21);
        ftp.setFileType(FTP.BINARY_FILE_TYPE);
        ftp.user("toNSite");
        ftp.pass("tonMotDePasse");
        InputStream is0 = new FileInputStream(date + ".html");
        InputStream is = new FileInputStream(date + ".wav");
        ftp.storeFile("/uploads/" + date + ".html", is0);
        ftp.storeFile("/uploads/" + date + ".wav", is);
        is.close();
        Desktop.getDesktop().browse(new URI("http://focaliser.fr/uploads/" + date + ".html"));
    } catch (MalformedURLException ex) {
        Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (URISyntaxException ex) {
        Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.fabric3.transport.ftp.server.host.F3FtpHostTest.java

public void testValidLogin() throws IOException {
    FTPClient ftpClient = new FTPClient();
    ftpClient.connect(InetAddress.getLocalHost(), 1234);
    ftpClient.user("user");
    assertEquals(230, ftpClient.pass("password"));
}

From source file:org.fabric3.transport.ftp.server.host.F3FtpHostTest.java

public void testInvalidLogin() throws IOException {
    FTPClient ftpClient = new FTPClient();
    ftpClient.connect(InetAddress.getLocalHost(), 1234);
    ftpClient.user("user");
    assertEquals(530, ftpClient.pass("password1"));
}

From source file:org.fabric3.transport.ftp.server.host.F3FtpHostTest.java

public void testStor() throws IOException {
    FTPClient ftpClient = new FTPClient();
    ftpClient.connect(InetAddress.getLocalHost(), 1234);
    ftpClient.user("user");
    ftpClient.pass("password");
    ftpClient.enterLocalPassiveMode();/*from  ww  w .  j a v  a 2 s  .  co m*/
    ftpClient.storeFile("/resource/test.dat", new ByteArrayInputStream("TEST\r\n".getBytes()));
}