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


Java IoUtils.copyStream方法代码示例

本文整理汇总了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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BaseDiskCache.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:LruDiskCache.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:20,代码来源:LruDiscCache.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:LruDiskCache.java

示例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;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:24,代码来源:BaseDiscCache.java

示例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;
}
 
开发者ID:jiangqqlmj,项目名称:Android-Universal-Image-Loader-Modify,代码行数:34,代码来源:BaseDiskCache.java

示例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;
}
 
开发者ID:jiangqqlmj,项目名称:Android-Universal-Image-Loader-Modify,代码行数:33,代码来源:LruDiskCache.java

示例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;
}
 
开发者ID:nakaken0629,项目名称:iped,代码行数:18,代码来源:UpdateAsyncTask.java

示例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;
}
 
开发者ID:x251089003,项目名称:EveryXDay,代码行数:28,代码来源:BaseDiscCache.java

示例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;
}
 
开发者ID:Apokrif,项目名称:morse,代码行数:16,代码来源:LoadAndDisplayImageTask.java


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