项目:zimdroid
文件:ZimContentProvider.java
@Override
public ParcelFileDescriptor openFile(Uri uri,String mode) throws FileNotFoundException {
ParcelFileDescriptor[] pipe;
try {
pipe = ParcelFileDescriptor.createPipe();
String url = getFilePath(uri);
Log.d(TAG,"Retrieving " + url);
ByteArrayOutputStream stream = getDataForUrl(url);
new TransferThread(stream,new AutoCloSEOutputStream(pipe[1])).start();
} catch (IOException e) {
e.printstacktrace();
throw new FileNotFoundException("Could not open pipe for: " + uri.toString());
}
return (pipe[0]);
}
项目:samba-documents-provider
文件:ReadFileTask.java
@Override
public Void doInBackground(Void... args) {
try (final AutoCloSEOutputStream os = new AutoCloSEOutputStream(mPfd);
final SmbFile file = mClient.openFile(mUri,"r")) {
int size;
byte[] buf = new byte[mBuffer.capacity()];
while ((size = file.read(mBuffer,Integer.MAX_VALUE)) > 0) {
mBuffer.get(buf,size);
os.write(buf,size);
mBuffer.clear();
}
} catch (IOException e) {
Log.e(TAG,"Failed to read file.",e);
try {
mPfd.closeWithError(e.getMessage());
} catch (IOException exc) {
Log.e(TAG,"Can't even close PFD with error.",exc);
}
}
return null;
}
项目:SimpleKiwixWikivoyage
文件:ZimContentProvider.java
@Override
public ParcelFileDescriptor openFile(Uri uri,String mode)
throws FileNotFoundException {
ParcelFileDescriptor[] pipe = null;
try {
pipe = ParcelFileDescriptor.createPipe();
new TransferThread(jniKiwix,uri,new AutoCloSEOutputStream(
pipe[1])).start();
} catch (IOException e) {
Log.e(getClass().getSimpleName(),"Exception opening pipe",e);
throw new FileNotFoundException("Could not open pipe for: "
+ uri.toString());
}
return (pipe[0]);
}
/**
* {@inheritDoc}
*/
@Override
public ParcelFileDescriptor openFile(Uri uri,String mode)
throws FileNotFoundException {
if ("r".equals(mode)) {
ParcelFileDescriptor[] pipe=null;
try {
pipe=ParcelFileDescriptor.createPipe();
new TransferOutThread(getInputStream(uri),new AutoCloSEOutputStream(pipe[1])).start();
}
catch (IOException e) {
Log.e(getClass().getSimpleName(),e);
throw new FileNotFoundException("Could not open pipe for: "
+ uri.toString());
}
return(pipe[0]);
}
throw new IllegalArgumentException("Cannot support writing!");
}
项目:facebook-content-provider
文件:PipeContentProvider.java
@Override
public ParcelFileDescriptor openFile(Uri uri,String mode) {
ParcelFileDescriptor[] pipe = null;
try {
pipe = ParcelFileDescriptor.createPipe();
new TransferThread(getInputStream(uri),new AutoCloSEOutputStream(pipe[1])).start();
}
catch (IOException e) {
Log.e("PipeContentProvider",e);
}
return pipe[0];
}
项目:FMTech
文件:jsz.java
public final void a(ParcelFileDescriptor paramParcelFileDescriptor,Object paramObject)
{
String str1 = String.valueOf(iaw.b(Long.valueOf(this.a)));
String str2;
if (str1.length() != 0) {
str2 = "PicasaStore.download ".concat(str1);
}
for (;;)
{
int i = jsm.a(str2);
InputStream localInputStream = this.b;
ParcelFileDescriptor.AutoCloSEOutputStream localAutoCloSEOutputStream = new ParcelFileDescriptor.AutoCloSEOutputStream(paramParcelFileDescriptor);
try
{
byte[] arrayOfByte = new byte[2048];
int j = localInputStream.read(arrayOfByte);
for (;;)
{
if (j > 0)
{
localAutoCloSEOutputStream.write(arrayOfByte,j);
int k = localInputStream.read(arrayOfByte);
j = k;
continue;
str2 = new String("PicasaStore.download ");
break;
}
}
return;
}
catch (IOException localIOException)
{
String str3 = String.valueOf(localIOException);
new StringBuilder(29 + String.valueOf(str3).length()).append("pipe closed early by caller? ").append(str3);
return;
}
catch (Throwable localThrowable) {}finally
{
iaw.a(localAutoCloSEOutputStream);
iaw.a(localInputStream);
jsm.a(i);
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。