Equivalent Scala code for Java code

arun

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.

nmat

To cast to a different type in Scala use:

session.openChannel("sftp").asInstanceOf[ChannelSftp]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What is the Java equivalent of this Scala code?

From Dev

Is this Python code equivalent of Java code?

From Dev

What is the equivalent Scala code for this Imperative coding style?

From Dev

Unable to use java code in scala

From Dev

What is the equivalent of this snippet of Java code in C#?

From Dev

What is this Java code equivalent in C# ? (setRequestEntity)

From Dev

What is this Java code equivalent in C# ? (setRequestEntity)

From Dev

Javascript/NodeJS equivalent code for the Java code Cipher.doFinal(byte[])?

From Dev

Equivalent java code statement for C code statement used in recursion

From Dev

Is this Haskell code equivalent to this Python code?

From Dev

Is this Haskell code equivalent to this Python code?

From Dev

What is the code equivalent to this css code?

From Dev

Equivalent of Java '?' in Scala

From Dev

Equivalent to Java summaryStatistics in Scala

From Dev

Are these lines of JavaScript code equivalent?

From Dev

Haskell equivalent of this Python code

From Dev

C# Equivalent to this code

From Dev

Matlab equivalent code for file

From Dev

%timeit equivalent in code

From Dev

Equivalent code in IronPython

From Dev

C# Equivalent to this code

From Dev

Matlab equivalent code for file

From Dev

sed equivalent code for AIX

From Dev

Equivalent code without the library

From Dev

Is this Swift code equivalent?

From Dev

Maven: build Scala code and Java code together into a Fat JAR

From Dev

Running Java/Scala code from R

From Dev

"Trickiness" to calling Scala code from Java?

From Dev

How to execute OCaml code from Scala/Java?