当前位置: 首页>>代码示例>>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;未经允许,请勿转载。