项目:samba-documents-provider
文件:WriteFileTask.java
@Override
public Void doInBackground(Void... args) {
try (final AutoCloseInputStream is = new AutoCloseInputStream(mPfd);
final SmbFile file = mClient.openFile(mUri,"w")){
int size;
byte[] buf = new byte[mBuffer.capacity()];
while ((size = is.read(buf)) > 0) {
mBuffer.put(buf,size);
file.write(mBuffer,size);
mBuffer.clear();
}
} catch (IOException e) {
Log.e(TAG,"Failed to write file.",e);
try {
mPfd.closeWithError(e.getMessage());
} catch (IOException exc) {
Log.e(TAG,"Can't even close PFD with error.",exc);
}
}
return null;
}
项目:q-mail
文件:ParcelFileDescriptorUtil.java
public static TransferThread pipeto(OutputStream outputStream,ParcelFileDescriptor output)
throws IOException {
AutoCloseInputStream InputStream = new AutoCloseInputStream(output);
TransferThread t = new TransferThread(InputStream,outputStream);
t.start();
return t;
}
项目:q-mail
文件:ParcelFileDescriptorUtil.java
public static <T> DataSinkTransferThread<T> asyncPipetoDataSink(
SMimeDataSink<T> dataSink,ParcelFileDescriptor output) throws IOException {
InputStream inputStream = new BufferedInputStream(new AutoCloseInputStream(output));
DataSinkTransferThread<T> dataSinkTransferThread =
new DataSinkTransferThread<T>(dataSink,inputStream);
dataSinkTransferThread.start();
return dataSinkTransferThread;
}
项目:q-mail
文件:ParcelFileDescriptorUtil.java
public static <T> DataSinkTransferThread<T> asyncPipetoDataSink(
OpenPgpDataSink<T> dataSink,inputStream);
dataSinkTransferThread.start();
return dataSinkTransferThread;
}
项目:K9-MailClient
文件:ParcelFileDescriptorUtil.java
public static TransferThread pipeto(OutputStream outputStream,outputStream);
t.start();
return t;
}
项目:K9-MailClient
文件:ParcelFileDescriptorUtil.java
public static <T> DataSinkTransferThread<T> asyncPipetoDataSink(
OpenPgpDataSink<T> dataSink,inputStream);
dataSinkTransferThread.start();
return dataSinkTransferThread;
}
项目:QuizUpWinner
文件:Request.java
public void writeFile(String paramString1,ParcelFileDescriptor paramParcelFileDescriptor,String paramString2)
{
if (paramString2 == null)
paramString2 = "content/unkNown";
writeContentdisposition(paramString1,paramString1,paramString2);
int i = 0;
if ((this.outputStream instanceof ProgressNoopOutputStream))
{
((ProgressNoopOutputStream)this.outputStream).addProgress(paramParcelFileDescriptor.getStatSize());
i = 0;
}
else
{
ParcelFileDescriptor.AutoCloseInputStream localAutoCloseInputStream = null;
BufferedInputStream localBufferedInputStream = null;
try
{
localAutoCloseInputStream = new ParcelFileDescriptor.AutoCloseInputStream(paramParcelFileDescriptor);
localBufferedInputStream = new BufferedInputStream(localAutoCloseInputStream);
byte[] arrayOfByte = new byte[8192];
while (true)
{
int j = localBufferedInputStream.read(arrayOfByte);
if (j == -1)
break;
this.outputStream.write(arrayOfByte,j);
i += j;
}
localBufferedInputStream.close();
localAutoCloseInputStream.close();
}
finally
{
if (localBufferedInputStream != null)
localBufferedInputStream.close();
if (localAutoCloseInputStream != null)
localAutoCloseInputStream.close();
}
}
writeLine("",new Object[0]);
writeRecordBoundary();
if (this.logger != null)
{
Logger localLogger = this.logger;
String str = " " + paramString1;
Object[] arrayOfObject = new Object[1];
arrayOfObject[0] = Integer.valueOf(i);
localLogger.appendkeyvalue(str,String.format("<Data: %d>",arrayOfObject));
}
}
项目:silent-contacts-android
文件:ScContactsProvider.java
@Override
protected Object doInBackground(Object... params) {
AutoCloseInputStream is = new AutoCloseInputStream(mDescriptor);
try {
Bitmap b = BitmapFactory.decodeStream(is);
if (b != null) {
waitForAccess(mWriteAccessLatch);
PhotoProcessor processor = new PhotoProcessor(b,getMaxdisplayPhotoDim(),getMaxThumbnailDim());
// Store the compressed photo in the photo store.
PhotoStore photoStore = mContactsPhotoStore;
long photoFileId = photoStore.insert(processor);
// Depending on whether we already had a data row to attach the photo
// to,do an update or insert.
if (mDataId != 0) {
// Update the data record with the new photo.
ContentValues updateValues = new ContentValues();
// Signal that photo processing has already been handled.
updateValues.put(DaTarowHandlerForPhoto.SKIP_PROCESSING_KEY,true);
if (photoFileId != 0) {
updateValues.put(Photo.PHOTO_FILE_ID,photoFileId);
}
updateValues.put(Photo.PHOTO,processor.getThumbnailPhotoBytes());
update(ContentUris.withAppendedId(Data.CONTENT_URI,mDataId),updateValues,null,null);
}
else {
// Insert a new primary data record with the photo.
ContentValues insertValues = new ContentValues();
// Signal that photo processing has already been handled.
insertValues.put(DaTarowHandlerForPhoto.SKIP_PROCESSING_KEY,true);
insertValues.put(Data.MIMETYPE,Photo.CONTENT_ITEM_TYPE);
insertValues.put(Data.IS_PRIMARY,1);
if (photoFileId != 0) {
insertValues.put(Photo.PHOTO_FILE_ID,photoFileId);
}
insertValues.put(Photo.PHOTO,processor.getThumbnailPhotoBytes());
insert(RawContacts.CONTENT_URI.buildUpon()
.appendpath(String.valueOf(mRawContactId))
.appendpath(RawContacts.Data.CONTENT_DIRECTORY).build(),insertValues);
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return null;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。