code: public SftpFile openDirectory(String path) throws SftpStatusException,
  			SshException {
  
  		String absolutePath = getAbsolutePath(path);
  
  		SftpFileAttributes attrs = getAttributes(absolutePath);
  
  		if (!attrs.isDirectory()) {
  			throw new SftpStatusException(SftpStatusException.SSH_FX_FAILURE,
  					path + " is not a directory");
  		}
  
  		try {
  			UnsignedInteger32 requestId = nextRequestId();
  			Packet msg = createPacket();
  			msg.write(SSH_FXP_OPENDIR);
  			msg.writeInt(requestId.longValue());
  			msg.writeString(path, CHARSET_ENCODING);
  			sendMessage(msg);
  
  			byte[] handle = getHandleResponse(requestId);
  
  			SftpFile file = new SftpFile(absolutePath, attrs);
  			file.setHandle(handle);
  			file.setSFTPSubsystem(this);
  
  			return file;
  		} catch (SshIOException ex) {
  			throw ex.getRealException();
  		} catch (IOException ex) {
  			throw new SshException(ex);
  		}
  
  	}
docs: Open a directory.
  
  @param path
  @return sftpfile
  @throws SftpStatusException
  , SshException