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


Java Helper.closeQuietly方法代码示例

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


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

示例1: save

import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
public static String save(Context context, File outFile, String html) {
    Reader in = null;
    Writer out = null;

    try {
        in = new StringReader(html);
        out = new FileWriter(outFile);

        IOUtils.copy(in, out);

        return outFile.getAbsolutePath();
    } catch (IOException ioe) {
        String toastMsg = context.getString(R.string.save_as_failure, ioe.getMessage());
        Toast.makeText(context, toastMsg, Toast.LENGTH_LONG).show();
    } finally {
        Helper.closeQuietly(in);
        Helper.closeQuietly(out);
    }

    return null;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:22,代码来源:FileHelper.java

示例2: load

import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
public static String load(Context context, String filePath) {
    File inFile = new File(filePath);
    Reader in = null;
    Writer out = null;

    try {
        in = new FileReader(inFile);
        out = new StringWriter();

        IOUtils.copy(in, out);

        return out.toString();
    } catch (IOException ioe) {
        String toastMsg = context.getString(R.string.load_failure_2, ioe.getMessage());
        Toast.makeText(context, toastMsg, Toast.LENGTH_LONG).show();
    } finally {
        Helper.closeQuietly(in);
        Helper.closeQuietly(out);
    }

    return null;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:23,代码来源:FileHelper.java

示例3: copyFile

import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
private void copyFile(InputStream in, File targetFile) {
    OutputStream out = null;
    try {
        out = new FileOutputStream(targetFile);
        IOUtils.copy(in, out);
    } catch (IOException ioe) {
        Log.e(getClass().getSimpleName(), ioe.getMessage(), ioe);
    } finally {
        Helper.closeQuietly(out);
        Helper.closeQuietly(in);
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:13,代码来源:RTMediaFactoryImpl.java

示例4: saveOutput

import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
private void saveOutput(Bitmap croppedImage) {
    if (mSaveUri != null) {
        OutputStream out = null;
        try {
            out = getContentResolver().openOutputStream(mSaveUri);
            if (out != null) {
                croppedImage.compress(mOutputFormat, 90, out);
            }
        } catch (IOException ex) {
            Log.e(getClass().getSimpleName(), "Cannot open file: " + mSaveUri, ex);
            setResult(RESULT_CANCELED);
            finish();
            return;
        } finally {
            Helper.closeQuietly(out);
        }

        Bundle extras = new Bundle();
        Intent intent = new Intent(mSaveUri.toString());
        intent.putExtras(extras);
        intent.putExtra(IMAGE_SOURCE_FILE, mImageSource);
        intent.putExtra(IMAGE_DESTINATION_FILE, mImageDest);
        intent.putExtra(ORIENTATION_IN_DEGREES,
                getOrientationInDegree(this));
        setResult(RESULT_OK, intent);

    } else {
        Log.e(getClass().getSimpleName(), "not defined image url");
    }
    croppedImage.recycle();
    finish();
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:33,代码来源:CropImageActivity.java

示例5: getPathFromUri

import com.onegravity.rteditor.utils.Helper; //导入方法依赖的package包/类
private static String getPathFromUri(Context context, Uri imageUri) {
    String filePath = "";

    if (imageUri.toString().startsWith("content://com.android.gallery3d.provider")) {
        imageUri = Uri.parse(imageUri.toString().replace("com.android.gallery3d", "com.google.android.gallery3d"));
    }

    Cursor cursor = null;
    try {
        String column = MediaColumns.DATA;
        String[] proj = {MediaColumns.DATA};

        cursor = context.getContentResolver().query(imageUri, proj, null, null, null);
        cursor.moveToFirst();

        if (imageUri.toString().startsWith("content://com.google.android.gallery3d")) {
            filePath = imageUri.toString();
        } else {
            filePath = cursor.getString(cursor.getColumnIndexOrThrow(column));
        }
    } catch (Exception ignore) {
        // Google Drive content provider throws an exception that we ignore
        // content://com.google.android.apps.docs.storage
    } finally {
        Helper.closeQuietly(cursor);
    }

    if (isNullOrEmpty(filePath) || !new File(filePath).exists() ||
            imageUri.toString().startsWith("content://com.google.android.gallery3d")) {
        filePath = imageUri.toString();
    }

    return filePath;
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:35,代码来源:MediaUtils.java


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