import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import com.LinuxUtil; String HOST = "<>"; String USER = "<>"; int port = <>; String command = << provide desired SFTP command you would like to execute>> String privatekeyPath = "<>"; InputStream inputStream = null; Session session = null; try { session = LinuxUtil.getRemoteSessionObject(HOST, USER, true,privatekeyPath,port); if(session!=null){ } inputStream = LinuxUtil.executeCommand(session, command); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder builder = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { builder.append(line); builder.append("\n"); //appende a new line } } catch (IOException e) { e.printStackTrace(); } finally { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } System.out.println(builder.toString()); service.getLogger().info("Output::::::::::::"+builder.toString()); session.disconnect(); } catch (JSchException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }