本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例9: closeQuietly
import com.onegravity.rteditor.utils.io.IOUtils; //導入依賴的package包/類
public static void closeQuietly(Closeable closeable) {
IOUtils.closeQuietly(closeable);
}