當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。