全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

判断文件是否存在(Java)

最近更新时间:2025-09-30 14:24:01

public void doesObjectExist() {
    // 初始化 Ks3Client,参见“初始化”文档
    Ks3Client ks3Client = initKs3Client();

    try {
        // 判断对象是否存在
        boolean exist = ks3Client.objectExists("bucketName", "objectKey");
        System.out.println("Object exists: " + exist);
    } catch (Ks3ServiceException e) {
        System.out.println("Ks3ServiceException occurred, which means the request was made to KS3, but KS3 returned an error response for some reason.");
        System.out.println("Error Message: " + e.getErrorMessage());
        System.out.println("Error Code: " + e.getErrorCode());
        System.out.println("Request ID: " + e.getRequestId());
    } catch (Ks3ClientException e) {
        System.out.println("Ks3ClientException occurred, which means the client encountered an internal error while trying to communicate with KS3.");
        System.out.println("Error Message: " + e.getMessage());
    } finally {
        // 不再使用时,关闭 Ks3Client
        ks3Client.shutdown();
    }
} 

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈