1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import it.sauronsoftware.ftp4j.FTPClient fun main() { val ftpClient = FTPClient() try { ftpClient.connect("ftp.rediris.es") ftpClient.login("anonymous", "guest") ftpClient.type = FTPClient.TYPE_BINARY val files = ftpClient.list("/") for (file in files) { if (file.type == 0) { println("Archivo: ${file.name}") } else if (file.type == 1) { println("Carpeta: ${file.name}") } } } catch (e: Exception) { e.printStackTrace() } finally { try { ftpClient.disconnect(true) } catch (e: Exception) { e.printStackTrace() } } } |