当前位置: 首页>>代码示例>>Java>>正文


Java SftpException.printStackTrace方法代码示例

本文整理汇总了Java中com.jcraft.jsch.SftpException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java SftpException.printStackTrace方法的具体用法?Java SftpException.printStackTrace怎么用?Java SftpException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jcraft.jsch.SftpException的用法示例。


在下文中一共展示了SftpException.printStackTrace方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public boolean delete(String srcPath) throws IOException {
	System.out.println("delete "+getAbsolutePath(srcPath));
	try {
		EncFSFileInfo file = getFileInfo(srcPath);
		if (!file.isDirectory()){
			getSession().rm(getAbsolutePath(srcPath));
			return true;
		}
		else {
			getSession().rmdir(getAbsolutePath(srcPath));
			return true;
		}
		
	} catch (SftpException e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:20,代码来源:FileProvider6.java

示例2: uploadFile

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
/**
 * Upload a single file to the sFTP server.未支持断点续传
 *
 * @param localFilePath       Path of the file on local computer
 * @param remoteDirectoryPath path of directory where the file will be stored
 * @return true if the file was uploaded successfully, false otherwise
 * @throws IOException if any network or IO error occurred.
 */
@Override
public void uploadFile(String localFilePath, String remoteDirectoryPath, boolean logProcess) throws FtpException {

    if (!Paths.get(localFilePath).toFile().exists()) {
        throw new FtpException("Unable to upload file, file does not exist :  " + localFilePath);
    }

    if (!existsDirectory(remoteDirectoryPath))
        createDirectory(remoteDirectoryPath);

    try {
        channel.put(localFilePath, remoteDirectoryPath);
    } catch (SftpException e) {
        e.printStackTrace();
        throw new FtpException("Unable to upload file :  " + localFilePath);
    }

    logger.info("upload file succeed : " + localFilePath);
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:28,代码来源:SftpConnection.java

示例3: createDirectory

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
/**
 * Create a directory and all missing parent-directories.
 * <p>
 * 设为 private ,不会有在服务器上仅仅创建文件夹的需求。
 *
 * @param remoteDirectoryPath
 * @throws IOException
 */
private void createDirectory(String remoteDirectoryPath) {

    String originalWorkingDirectory = getWorkingDirectory();

    String[] folders = remoteDirectoryPath.split("/");
    for (String folder : folders) {
        if (folder.length() > 0) {
            try {
                channel.cd(folder);
            } catch (SftpException e) {
                try {
                    channel.mkdir(folder);
                    channel.cd(folder);
                } catch (SftpException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    logger.info("create remote Directory '" + remoteDirectoryPath + "' succeed.");
    //还原当前目录
    changeDirectory(originalWorkingDirectory);
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:32,代码来源:SftpConnection.java

示例4: put

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
private void put(ChannelSftp cftp) throws SftpIOException {
    // the below is just the replacement for one code line:
    // cftp.put(srcFileName, dstFileName);
    // (connected with #184068 -  Instable remote unit tests failure)
    int attempt = 0;
    while (true) {
        attempt++;
        try {
            cftp.put(parameters.srcFile.getAbsolutePath(), parameters.dstFileName);
            if (attempt > 1) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.log(Level.FINE, "Success on attempt {0} to copy {1} to {2}:{3} :\n",
                            new Object[] {attempt, parameters.srcFile.getAbsolutePath(), execEnv, parameters.dstFileName});
                }
            }
            return;
        } catch (SftpException e) {
            if (attempt > PUT_RETRY_COUNT) {
                throw decorateSftpException(e, parameters.dstFileName);
            } else {
                if (LOG.isLoggable(Level.FINE) || attempt == 2) {
                    String message = String.format("Error on attempt %d to copy %s to %s:%s :\n", // NOI18N
                            attempt, parameters.srcFile.getAbsolutePath(), execEnv, parameters.dstFileName);
                    LOG.log(Level.FINE, message, e);
                    if (attempt == 2) {
                        Logger.fullThreadDump(message);
                    }
                }
                e.printStackTrace(System.err);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:SftpSupport.java

示例5: move

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public boolean move(String srcPath, String dstPath) throws IOException {
	try {
		getSession().rename(getAbsolutePath(srcPath),getAbsolutePath(dstPath));
		return true;
	} catch (SftpException e){
		e.printStackTrace();
		return false;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:11,代码来源:FileProvider6.java

示例6: mkdir

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public boolean mkdir(String dirPath) throws IOException {
	try {
		getSession().mkdir(getAbsolutePath(dirPath));
		return true;
	} catch (SftpException e){
		e.printStackTrace();
		return false;
	}		
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:11,代码来源:FileProvider6.java

示例7: mkdirs

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public boolean mkdirs(String dirPath) throws IOException {
	try {
		getSession().mkdir(getAbsolutePath(dirPath));
		return true;
	} catch (SftpException e){
		e.printStackTrace();
		return false;
	}		
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:11,代码来源:FileProvider6.java

示例8: createFile

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public EncFSFileInfo createFile(String dstFilePath) throws IOException {
	try {
		getSession().put(getAbsolutePath(dstFilePath));
		return getFileInfo(dstFilePath);
	} catch (SftpException e){
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:11,代码来源:FileProvider6.java

示例9: fsDownload

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public InputStream fsDownload(String path, long startIndex) throws IOException {
	System.out.println("download file "+path);
	try {
		BufferedInputStream is = new BufferedInputStream(getNewSession().get(getAbsolutePath(path)));
		if (startIndex>0) is.skip(startIndex);
		return is;
	} catch (SftpException e){
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:13,代码来源:FileProvider6.java

示例10: fsUpload

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public OutputStream fsUpload(String path, long length)  {
	try {
		return getNewSession().put(getAbsolutePath(path));
	} catch (SftpException e){
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:10,代码来源:FileProvider6.java

示例11: mkdir

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
public boolean mkdir(String path) {
    try {
        channelSftp.mkdir(path);
        return true;
    } catch (SftpException e) {
        e.printStackTrace();
        return (e.id != 3);
    }
}
 
开发者ID:konachan700,项目名称:SSHFileManager,代码行数:10,代码来源:SSHHelper.java

示例12: getCurrentDir

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
public String getCurrentDir() {
    try {
        return channelSftp.pwd();
    } catch (SftpException e) {
        e.printStackTrace();
        return "/";
    }
}
 
开发者ID:konachan700,项目名称:SSHFileManager,代码行数:9,代码来源:SSHHelper.java

示例13: existsFile

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
/**
     * Determines whether a file exists or not
     * 如果是文件夹,返回 false
     *
     * @param remoteFilePath
     * @return true if exists, false otherwise
     * @throws IOException thrown if any I/O error occurred.
     */
    @Override
    public boolean existsFile(String remoteFilePath) {


        try {
            // System.out.println(channel.realpath(remoteFilePath));
            SftpATTRS attrs = channel.stat(remoteFilePath);
            return attrs.isReg();
        } catch (SftpException e) {
            e.printStackTrace();
            return false;
        }

//        try {
//            // ls 命令
//            // 如果是文件夹或文件夹的符号链接,会进入该文件夹,进行列表,则文件个数会大于 1
//            // 如果是文件,则只会返回该文件本身,文件个数 =1
//            Vector<LsEntry> lsEntries = channel.ls(remoteFilePath);
//
//            for(LsEntry entry:lsEntries)
//               System.out.println(entry.getFilename());
//
//            return lsEntries.size() == 1;
//        } catch (SftpException e) {
//            e.printStackTrace();
//            return false;
//        }

    }
 
开发者ID:h819,项目名称:spring-boot,代码行数:38,代码来源:SftpConnection.java

示例14: setEncoding

import com.jcraft.jsch.SftpException; //导入方法依赖的package包/类
@Override
public void setEncoding(String encoding) {
    try {
        this.channel.setFilenameEncoding(encoding);
        super.setEncoding(encoding);
    } catch (SftpException e) {
        e.printStackTrace();
    }
}
 
开发者ID:uom-daris,项目名称:daris,代码行数:10,代码来源:JschSftpClient.java


注:本文中的com.jcraft.jsch.SftpException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。