當前位置: 首頁>>代碼示例>>Java>>正文


Java FileInputStream.getFD方法代碼示例

本文整理匯總了Java中java.io.FileInputStream.getFD方法的典型用法代碼示例。如果您正苦於以下問題:Java FileInputStream.getFD方法的具體用法?Java FileInputStream.getFD怎麽用?Java FileInputStream.getFD使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.FileInputStream的用法示例。


在下文中一共展示了FileInputStream.getFD方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testReadAndWrite

import java.io.FileInputStream; //導入方法依賴的package包/類
@Test(timeout=10000)
public void testReadAndWrite() throws Exception {
  File path = new File(TEST_BASE, "testReadAndWrite");
  path.mkdirs();
  SharedFileDescriptorFactory factory =
      SharedFileDescriptorFactory.create("woot_",
          new String[] { path.getAbsolutePath() });
  FileInputStream inStream =
      factory.createDescriptor("testReadAndWrite", 4096);
  FileOutputStream outStream = new FileOutputStream(inStream.getFD());
  outStream.write(101);
  inStream.getChannel().position(0);
  Assert.assertEquals(101, inStream.read());
  inStream.close();
  outStream.close();
  FileUtil.fullyDelete(path);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:18,代碼來源:TestSharedFileDescriptorFactory.java

示例2: transfer

import java.io.FileInputStream; //導入方法依賴的package包/類
static public long transfer(long position, long count, FileInputStream src, FileOutputStream dst) throws IOException {
    FileChannel srcChannel = src.getChannel();
    FileChannel dstChannel = dst.getChannel();
    if (!srcChannel.isOpen()) {
        throw new ClosedChannelException();
    }
    if (!dstChannel.isOpen()) {
        throw new ClosedChannelException();
    }

    if (position < 0 || count < 0) {
        throw new IllegalArgumentException("position=" + position + " count=" + count);
    }

    if (count == 0 || position >= srcChannel.size()) {
        return 0;
    }
    count = Math.min(count, srcChannel.size() - position);

    FileDescriptor inFd = src.getFD();
    FileDescriptor outFd = dst.getFD();
    long rc = 0;
    rc = native_sendfile_64(outFd, inFd, position, count);
    return rc;
}
 
開發者ID:archos-sa,項目名稱:aos-FileCoreLibrary,代碼行數:26,代碼來源:ArchosFileChannel.java

示例3: loadBitmapFromDiskCache

import java.io.FileInputStream; //導入方法依賴的package包/類
private Bitmap loadBitmapFromDiskCache(String url, int reqWidth, int reqHeight) throws IOException {
    if (Looper.myLooper() == Looper.getMainLooper()) {
        Log.w(TAG, "load bitmap from UI thread, it's not recommended!");
    }

    if (mDiskLruCache == null) {
        return null;
    }

    Bitmap bitmap = null;
    String key = hashKeyFormUrl(url);
    DiskLruCache.Snapshot snapshot = mDiskLruCache.get(key);
    if (snapshot != null) {
        FileInputStream fileInputStream = (FileInputStream) snapshot.getInputStream(DISK_CACHE_INDEX);
        FileDescriptor fileDescriptor = fileInputStream.getFD();
        bitmap = ImageResizeUtil.decodeBitmapFromFileDescriptor(fileDescriptor, reqWidth, reqHeight);
        if (bitmap != null) {
            addBitmapToMemoryCache(key, bitmap);
        }
    }

    return bitmap;
}
 
開發者ID:DysaniazzZ,項目名稱:ArtOfAndroid,代碼行數:24,代碼來源:ImageLoadUtil.java

示例4: loadBitmapFromDiskCache

import java.io.FileInputStream; //導入方法依賴的package包/類
/**
 * 在存儲緩存中讀取Bitmap
 * @param url
 * @param reqWidth
 * @param reqHeight
 * @return
 * @throws IOException
 */
private Bitmap loadBitmapFromDiskCache(String url, int reqWidth, int reqHeight) throws IOException{
    if(Looper.myLooper() == Looper.getMainLooper()){
        throw new RuntimeException("can not visit network from UI Thread.");
    }
    if(mDiskLruCache == null){
        return null;
    }
    Bitmap bitmap = null;
    String key = hashKeyFromUrl(url);
    DiskLruCache.Snapshot snapshot = mDiskLruCache.get(key);
    if(snapshot != null){
        FileInputStream fileInputStream = (FileInputStream) snapshot.getInputStream(DISK_CACHE_INDEX);
        //文件描述
        FileDescriptor fileDescriptor = fileInputStream.getFD();
        bitmap = mImageResizer.decodeSampleeBitmapFromFileDescriptor(fileDescriptor,reqWidth,reqHeight);
        if(bitmap != null){
            //添加到內存緩存
            addBitmapToMemoryCache(key,bitmap);
        }
    }
    return bitmap;
}
 
開發者ID:Jiabaokang,項目名稱:JBKWeather,代碼行數:31,代碼來源:ImageLoader.java

示例5: setDataSource

import java.io.FileInputStream; //導入方法依賴的package包/類
/**
  * Sets the data source (file-path or http/rtsp URL) to use.
  *
  * @param path the path of the file, or the http/rtsp URL of the stream you want to play
  * @param keys   AVOption key
  * @param values AVOption value
  * @throws IllegalStateException if it is called in an invalid state
  */
public void setDataSource(String path, String[] keys, String[] values) throws IOException, IllegalArgumentException, SecurityException, IllegalStateException {
	final Uri uri = Uri.parse(path);
	if ("file".equals(uri.getScheme())) {
		path = uri.getPath();
	}

	final File file = new File(path);
	if (file.exists()) {
		FileInputStream is = new FileInputStream(file);
		FileDescriptor fd = is.getFD();
		setDataSource(fd);
		is.close();
	} else {
		_setDataSource(path, keys, values);
	}
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:25,代碼來源:MediaPlayer.java


注:本文中的java.io.FileInputStream.getFD方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。