I am new to scala.Any one having idea what is the equivalent code in scala for the following java code
package sampleFTP
import org.apache.commons.net.ftp.FTPClient
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
import com.jcraft.jsch._
object FTPTest {
def main(args: Array[String]) {
println("Hello, world!")
var ftpClient= new FTPClient();
val SFTPPASS = "xxxx";
val SFTPWORKINGDIR = "/xxxx/xxxx";
System.out.println("preparing the host information for sftp.");
val jsch = new JSch();
var session = jsch.getSession("xxxx", "xxxx", 22)
session.setPassword(SFTPPASS);
var config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect();
System.out.println("Host connected.");
var channel = session.openChannel("sftp");
channel.connect();
System.out.println("sftp channel opened and connected.");
var sftpChannel = (ChannelSftp) session.openChannel("sftp");//error in this line
System.out.println("Directory:" + sftpChannel.pwd());
session.disconnect();
}
}
I am getting the following error
value session is not a member of object com.jcraft.jsch.ChannelSftp
I have Successfully implemented the secure FTP
connection using jsch
.How to download and list file via jsch
in scala
.