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


Java IOUtils类代码示例

本文整理汇总了Java中com.onegravity.rteditor.utils.io.IOUtils的典型用法代码示例。如果您正苦于以下问题:Java IOUtils类的具体用法?Java IOUtils怎么用?Java IOUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IOUtils类属于com.onegravity.rteditor.utils.io包,在下文中一共展示了IOUtils类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAssetIndex

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的package包/类
static List<String> getAssetIndex(Context context) {
    if (mAssetIndex.isEmpty()) {
        InputStream in = null;
        BufferedReader reader  = null;
        try {
            in = context.getAssets().open("assets.index");
            reader = new BufferedReader(new InputStreamReader(in));
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                mAssetIndex.add(line);
            }
        } catch (final IOException e) {
            Log.e(AssetIndex.class.getSimpleName(), e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(reader);
        }
    }

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

示例2: downloadFile

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的package包/类
private InputStream downloadFile(String sourceFile) {
    InputStream in = null;
    try {
        URL url = new URL(sourceFile);
        final HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        in = new BufferedInputStream(urlConnection.getInputStream()) {
            @Override
            public void close() throws IOException {
                super.close();
                urlConnection.disconnect();
            }
        };
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), e.getMessage(), e);
        IOUtils.closeQuietly(in);
    }

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

示例3: downloadFile

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的package包/类
private InputStream downloadFile(String sourceFile) {
    InputStream in = null;
    try {
        URL url = new URL(sourceFile);
        final HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        in = new BufferedInputStream(urlConnection.getInputStream()) {
            public void close() throws IOException {
                super.close();
                urlConnection.disconnect();
            }
        };
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), e.getMessage(), e);
        IOUtils.closeQuietly(in);
    }

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

示例4: save

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的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

示例5: load

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的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

示例6: getAssetIndex

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的package包/类
static List<String> getAssetIndex(Context context) {
    if (mAssetIndex.isEmpty()) {
        InputStream in = null;
        BufferedReader reader  = null;
        try {
            in = context.getAssets().open("assets.index");
            reader = new BufferedReader(new InputStreamReader(in));
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                mAssetIndex.add(line);
            }
        } catch (final IOException e) {
            Log.w(AssetIndex.class.getSimpleName(), "The assets.index file could not be read. If you want to use your own fonts, please copy the fonts to the assets folder and the build code to generate the assets.index file into your build.gradle (for more details consult the readme, chapter fonts)", e);
        } finally {
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(reader);
        }
    }

    return mAssetIndex;
}
 
开发者ID:1gravity,项目名称:Android-RTEditor,代码行数:21,代码来源:AssetIndex.java

示例7: getFontName

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的package包/类
/**
 * Retrieve the file name for a system font.
 *
 * @param filePath the full path for the font to retrieve.
 *
 * @return The file name or null of none could be retrieved.
 */
static String getFontName(String filePath) {
    TTFRandomAccessFile in = null;
    try {
        RandomAccessFile file = new RandomAccessFile(filePath, "r");
        in = new TTFRandomAccessFile(file);
        return getTTFFontName(in, filePath);
    } catch (IOException e) {
        return null;    // Missing permissions or corrupted font file?
    }
    finally {
        IOUtils.closeQuietly(in);
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:21,代码来源:TTFAnalyzer.java

示例8: copyFile

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的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

示例9: closeQuietly

import com.onegravity.rteditor.utils.io.IOUtils; //导入依赖的package包/类
public static void closeQuietly(Closeable closeable) {
    IOUtils.closeQuietly(closeable);
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:4,代码来源:Helper.java


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