本文整理汇总了Java中com.nostra13.universalimageloader.utils.IoUtils.copyStream方法的典型用法代码示例。如果您正苦于以下问题:Java IoUtils.copyStream方法的具体用法?Java IoUtils.copyStream怎么用?Java IoUtils.copyStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nostra13.universalimageloader.utils.IoUtils
的用法示例。
在下文中一共展示了IoUtils.copyStream方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
@Override
public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
File imageFile = getFile(imageUri);
File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX);
boolean loaded = false;
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize);
try {
loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize);
} finally {
IoUtils.closeSilently(os);
}
} finally {
if (loaded && !tmpFile.renameTo(imageFile)) {
loaded = false;
}
if (!loaded) {
tmpFile.delete();
}
}
return loaded;
}
示例2: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
@Override
public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
DiskLruCache.Editor editor = cache.edit(getKey(imageUri));
if (editor == null) {
return false;
}
OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize);
boolean copied = false;
try {
copied = IoUtils.copyStream(imageStream, os, listener, bufferSize);
} finally {
IoUtils.closeSilently(os);
if (copied) {
editor.commit();
} else {
editor.abort();
}
}
return copied;
}
示例3: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
public boolean save(String imageUri, InputStream imageStream, CopyListener listener) throws IOException {
boolean z = false;
Editor editor = this.cache.edit(getKey(imageUri));
if (editor != null) {
OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), this.bufferSize);
z = false;
try {
z = IoUtils.copyStream(imageStream, os, listener, this.bufferSize);
} finally {
IoUtils.closeSilently(os);
if (z) {
editor.commit();
} else {
editor.abort();
}
}
}
return z;
}
示例4: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
public boolean save(String imageUri, InputStream imageStream, CopyListener listener) throws
IOException {
boolean z = false;
Editor editor = this.cache.edit(getKey(imageUri));
if (editor != null) {
OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), this.bufferSize);
z = false;
try {
z = IoUtils.copyStream(imageStream, os, listener, this.bufferSize);
} finally {
IoUtils.closeSilently(os);
if (z) {
editor.commit();
} else {
editor.abort();
}
}
}
return z;
}
示例5: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
@Override
public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
File imageFile = getFile(imageUri);
File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX);
boolean loaded = false;
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize);
try {
loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize);
} finally {
IoUtils.closeSilently(os);
}
} finally {
IoUtils.closeSilently(imageStream);
if (loaded && !tmpFile.renameTo(imageFile)) {
loaded = false;
}
if (!loaded) {
tmpFile.delete();
}
}
return loaded;
}
示例6: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
/**
* 根据文件流进行保存到缓存文件中
* @param imageUri Original image URI 原图片URL地址作为生成缓存文件的文件名
* @param imageStream Input stream of image (shouldn't be closed in this method) 图片流
* @param listener 用于监听流保存本地的进度
* Listener for saving progress, can be ignored if you don't use
* {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
* progress listener} in ImageLoader calls
* @return
* @throws IOException
*/
@Override
public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
File imageFile = getFile(imageUri);
File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX);
boolean loaded = false;
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize);
try {
loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize);
} finally {
IoUtils.closeSilently(os);
}
} finally {
if (loaded && !tmpFile.renameTo(imageFile)) {
loaded = false;
}
if (!loaded) {
tmpFile.delete();
}
}
return loaded;
}
示例7: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
/**
* 把图片流数据保存到缓存中
* @param imageUri Original image URI 图像URL连接地址
* @param imageStream Input stream of image (shouldn't be closed in this method) 图片流
* @param listener 图片流拷贝监听器
* Listener for saving progress, can be ignored if you don't use
* {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
* progress listener} in ImageLoader calls
* @return
* @throws IOException
*/
@Override
public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
DiskLruCache.Editor editor = cache.edit(getKey(imageUri));
if (editor == null) {
return false;
}
//流写入文件
OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize);
boolean copied = false;
try {
copied = IoUtils.copyStream(imageStream, os, listener, bufferSize);
} finally {
IoUtils.closeSilently(os);
if (copied) {
editor.commit();
} else {
editor.abort();
}
}
return copied;
}
示例8: doInBackgroundInner
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
private Void doInBackgroundInner(String[] urls) throws IOException {
Log.d(TAG, "url = " + urls[0]);
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(urls[0]);
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
File download = new File(this.downloadPath);
download.mkdir();
File apk = new File(downloadPath, APK_NAME);
FileOutputStream outputStream = new FileOutputStream(apk);
IoUtils.copyStream(entity.getContent(), outputStream, null);
outputStream.close();
client.getConnectionManager().shutdown();
return null;
}
示例9: save
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
@Override
public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
File imageFile = getFile(imageUri);
File tmpFile = new File(imageFile.getAbsolutePath() + TEMP_IMAGE_POSTFIX);
boolean loaded = false;
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(tmpFile), bufferSize);
try {
loaded = IoUtils.copyStream(imageStream, os, listener, bufferSize);
} finally {
IoUtils.closeSilently(os);
}
}catch(Exception e){
//TODO:sd卡已满!!
e.printStackTrace();
} finally {
IoUtils.closeSilently(imageStream);
if (loaded && !tmpFile.renameTo(imageFile)) {
loaded = false;
}
if (!loaded) {
tmpFile.delete();
}
}
return loaded;
}
示例10: downloadImage
import com.nostra13.universalimageloader.utils.IoUtils; //导入方法依赖的package包/类
private boolean downloadImage(File targetFile) throws IOException {
InputStream is = getDownloader().getStream(uri, options.getExtraForDownloader());
boolean loaded;
try {
OutputStream os = new BufferedOutputStream(new FileOutputStream(targetFile), BUFFER_SIZE);
try {
loaded = IoUtils.copyStream(is, os, this);
} finally {
IoUtils.closeSilently(os);
}
} finally {
IoUtils.closeSilently(is);
}
return loaded;
}