paulushcgcj
11/8/2016 - 9:34 PM

SSHUtils.java

public static boolean existFile(String usuario,String senha, String host, int porta,String destino){

		ShellConnectionStream ssh = new ShellConnectionStream(usuario, senha, host, porta);
		try{
			ssh.connect();
			if(ssh.isReady()) {
				String retorno = ssh.write("[ -f " + destino +" ]  && echo 1 || echo 0 ");
				ssh.close();
				if(retorno != null){
					retorno = retorno.replace("\n", "");
					return  Long.parseLong(retorno) > 0;
				}
				return false;
			}
		}catch(Exception e){ e.printStackTrace(); }		
		return false;
	}