本文整理匯總了Java中android.os.ParcelFileDescriptor.createPipe方法的典型用法代碼示例。如果您正苦於以下問題:Java ParcelFileDescriptor.createPipe方法的具體用法?Java ParcelFileDescriptor.createPipe怎麽用?Java ParcelFileDescriptor.createPipe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.ParcelFileDescriptor
的用法示例。
在下文中一共展示了ParcelFileDescriptor.createPipe方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: openFile
import android.os.ParcelFileDescriptor; //導入方法依賴的package包/類
@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]);
}
示例2: testBadFileDescriptorProvider
import android.os.ParcelFileDescriptor; //導入方法依賴的package包/類
@SmallTest
@Feature({"Cronet"})
public void testBadFileDescriptorProvider() throws Exception {
TestUrlRequestCallback callback = new TestUrlRequestCallback();
UrlRequest.Builder builder =
new UrlRequest.Builder(NativeTestServer.getRedirectToEchoBody(), callback,
callback.getExecutor(), mTestFramework.mCronetEngine);
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
try {
UploadDataProvider dataProvider = UploadDataProviders.create(pipe[0]);
builder.setUploadDataProvider(dataProvider, callback.getExecutor());
builder.addHeader("Content-Type", "useless/string");
builder.build().start();
callback.blockForDone();
assertTrue(callback.mError.getCause() instanceof IllegalArgumentException);
} finally {
pipe[1].close();
}
}
示例3: pipeFrom
import android.os.ParcelFileDescriptor; //導入方法依賴的package包/類
public static ParcelFileDescriptor pipeFrom(InputStream inputStream)
throws IOException {
final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
final OutputStream output = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]);
new TransferThread(inputStream, output).start();
return pipe[0];
}
示例4: pipeFrom
import android.os.ParcelFileDescriptor; //導入方法依賴的package包/類
public static ParcelFileDescriptor pipeFrom(InputStream inputStream)
throws IOException {
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
ParcelFileDescriptor readSide = pipe[0];
ParcelFileDescriptor writeSide = pipe[1];
new TransferThread(inputStream, new ParcelFileDescriptor.AutoCloseOutputStream(writeSide))
.start();
return readSide;
}
示例5: startPumpThread
import android.os.ParcelFileDescriptor; //導入方法依賴的package包/類
public ParcelFileDescriptor startPumpThread() throws IOException {
if (writeSidePfd != null) {
throw new IllegalStateException("startPumpThread() must only be called once!");
}
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
ParcelFileDescriptor readSidePfd = pipe[0];
writeSidePfd = pipe[1];
new DataSourceTransferThread(this, new ParcelFileDescriptor.AutoCloseOutputStream(writeSidePfd)).start();
return readSidePfd;
}
示例6: pipeTo
import android.os.ParcelFileDescriptor; //導入方法依賴的package包/類
@SuppressWarnings("unused")
public static ParcelFileDescriptor pipeTo(OutputStream outputStream)
throws IOException {
final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
final InputStream input = new ParcelFileDescriptor.AutoCloseInputStream(pipe[0]);
new TransferThread(input, outputStream).start();
return pipe[1];
}
示例7: NativePipe
import android.os.ParcelFileDescriptor; //導入方法依賴的package包/類
public NativePipe() {
try {
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pipe[0]) {
private boolean closed = false;
@Override
public void close() throws IOException {
if (closed) return;
closed = true;
super.close();
outputStream.close();
}
};
outputStream = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]) {
private boolean closed = false;
@Override
public void close() throws IOException {
if (closed) return;
closed = true;
super.close();
inputStream.close();
}
};
} catch (IOException e) {
throw new RuntimeException(e);
}
}