• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RandomAccessMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.vfs2.util.RandomAccessMode的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessMode类的具体用法?Java RandomAccessMode怎么用?Java RandomAccessMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RandomAccessMode类属于org.apache.commons.vfs2.util包,在下文中一共展示了RandomAccessMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
/**
 * Returns an input/output stream to use to read and write the content of the file in an
 * random manner.
 * @param mode The RandomAccessMode.
 * @return A RandomAccessContent object to access the file.
 * @throws FileSystemException if an error occurs.
 */
public RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException
{
    /*
    if (getThreadData().getState() != STATE_NONE)
    {
        throw new FileSystemException("vfs.provider/read-in-use.error", file);
    }
    */

    // Get the content
    final RandomAccessContent rastr = fileObject.getRandomAccessContent(mode);

    FileRandomAccessContent rac = new FileRandomAccessContent(fileObject, rastr);
    this.getThreadData().addRastr(rac);
    streamOpened();

    // setState(STATE_OPENED);
    return rac;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:27,代码来源:DefaultFileContent.java


示例2: reloadFileObject

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
public static void reloadFileObject(LoadingInfo loadingInfo, long position) throws IOException {
  loadingInfo.getFileObject().refresh();
  long currentSize = loadingInfo.getFileObject().getContent().getSize();
  IOUtils.closeQuietly(loadingInfo.getObserableInputStreamImpl());
  RandomAccessContent randomAccessContent = loadingInfo.getFileObject().getContent().getRandomAccessContent(RandomAccessMode.READ);
  randomAccessContent.seek(position);
  loadingInfo.setLastFileSize(currentSize);
  ObservableInputStreamImpl observableStream = new ObservableInputStreamImpl(randomAccessContent.getInputStream(),0);
  loadingInfo.setObserableInputStreamImpl(observableStream);
  if (loadingInfo.isGziped()) {
    loadingInfo.setContentInputStream(new GZIPInputStream(observableStream));
  } else {
    loadingInfo.setContentInputStream(observableStream);
  }
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:16,代码来源:Utils.java


示例3: FtpRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
FtpRandomAccessContent(final FtpFileObject fileObject, RandomAccessMode mode)
{
    super(mode);

    this.fileObject = fileObject;
    // fileSystem = (FtpFileSystem) this.fileObject.getFileSystem();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:8,代码来源:FtpRandomAccessContent.java


示例4: SftpRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
SftpRandomAccessContent(final SftpFileObject fileObject, RandomAccessMode mode)
{
    super(mode);

    this.fileObject = fileObject;
    // fileSystem = (FtpFileSystem) this.fileObject.getFileSystem();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:8,代码来源:SftpRandomAccessContent.java


示例5: HttpRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
HttpRandomAccessContent(final HttpFileObject fileObject, RandomAccessMode mode)
{
    super(mode);

    this.fileObject = fileObject;
    fileSystem = (HttpFileSystem) this.fileObject.getFileSystem();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:8,代码来源:HttpRandomAccessContent.java


示例6: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
/**
 * random access
 */
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
    return new NfsFileRandomAccessContent(file, mode);
}
 
开发者ID:danniss,项目名称:common-vfs2-nfs,代码行数:9,代码来源:NfsFileObject.java


示例7: getRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
public RandomAccessContent getRandomAccessContent( final RandomAccessMode arg0 ) throws FileSystemException {
  // not needed for our usage
  return null;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:5,代码来源:MetadataToMondrianVfsFileContent.java


示例8: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
    return new HttpRandomAccessContent(this, mode);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:6,代码来源:HttpFileObject.java


示例9: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
/**
 * random access
 */
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
    return new SmbFileRandomAccessContent(file, mode);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:9,代码来源:SmbFileObject.java


示例10: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
    return new LocalFileRandomAccessContent(file, mode);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:6,代码来源:LocalFile.java


示例11: LocalFileRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
LocalFileRandomAccessContent(final File localFile, final RandomAccessMode mode) throws FileSystemException
{
    super(mode);

    try
    {
        raf = new RandomAccessFile(localFile, mode.getModeString());
        rafis = new InputStream()
        {
            @Override
            public int read() throws IOException
            {
                try
                {
                    return raf.readByte();
                }
                catch (EOFException e)
                {
                    return -1;
                }
            }

            @Override
            public long skip(long n) throws IOException
            {
                raf.seek(raf.getFilePointer() + n);
                return n;
            }

            @Override
            public void close() throws IOException
            {
                raf.close();
            }

            @Override
            public int read(byte[] b) throws IOException
            {
                return raf.read(b);
            }

            @Override
            public int read(byte[] b, int off, int len) throws IOException
            {
                return raf.read(b, off, len);
            }

            @Override
            public int available() throws IOException
            {
                long available = raf.length() - raf.getFilePointer();
                if (available > Integer.MAX_VALUE)
                {
                    return Integer.MAX_VALUE;
                }

                return (int) available;
            }
        };
    }
    catch (FileNotFoundException e)
    {
        throw new FileSystemException("vfs.provider/random-access-open-failed.error", localFile);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:66,代码来源:LocalFileRandomAccessContent.java


示例12: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode)
        throws Exception
{
    return new RamFileRandomAccessContent(this, mode);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:7,代码来源:RamFileObject.java


示例13: RamFileRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
/**
 * @param file The file to access.
 * @param mode The access mode.
 */
public RamFileRandomAccessContent(RamFileObject file, RandomAccessMode mode)
{
    super();
    this.buf = file.getData().getBuffer();
    this.file = file;
    this.mode = mode;

    rafis = new InputStream()
    {
        @Override
        public int read() throws IOException
        {
            try
            {
                return readByte();
            }
            catch (EOFException e)
            {
                return -1;
            }
        }

        @Override
        public long skip(long n) throws IOException
        {
            seek(getFilePointer() + n);
            return n;
        }

        @Override
        public void close() throws IOException
        {
        }

        @Override
        public int read(byte[] b) throws IOException
        {
            return read(b, 0, b.length);
        }

        @Override
        public int read(byte[] b, int off, int len) throws IOException
        {
            int retLen = Math.min(len, getLeftBytes());
            RamFileRandomAccessContent.this.readFully(b, off, retLen);
            return retLen;
        }

        @Override
        public int available() throws IOException
        {
            return getLeftBytes();
        }
    };
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:60,代码来源:RamFileRandomAccessContent.java


示例14: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
    return new FtpRandomAccessContent(this, mode);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:6,代码来源:FtpFileObject.java


示例15: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(
        final RandomAccessMode mode) throws Exception
{
    return new SftpRandomAccessContent(this, mode);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:7,代码来源:SftpFileObject.java


示例16: AbstractRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
protected AbstractRandomAccessContent(final RandomAccessMode mode)
{
    this.mode = mode;
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:5,代码来源:AbstractRandomAccessContent.java


示例17: AbstractRandomAccessStreamContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
protected AbstractRandomAccessStreamContent(final RandomAccessMode mode)
{
    super(mode);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:5,代码来源:AbstractRandomAccessStreamContent.java


示例18: doGetRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
/**
 * Creates access to the file for random i/o.
 * @since 2.0
 */
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
    return file.getContent().getRandomAccessContent(mode);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:10,代码来源:DelegateFileObject.java


示例19: getRandomAccessContent

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
/**
 * Returns an input/output stream to use to read and write the content of the file in and
 * random manner.
 * @param mode The RandomAccessMode.
 * @return The RandomAccessContent.
 * @throws FileSystemException if an error occurs.
 */
public RandomAccessContent getRandomAccessContent(final RandomAccessMode mode) throws FileSystemException
{
    /* VFS-210
    if (!getType().hasContent())
    {
        throw new FileSystemException("vfs.provider/read-not-file.error", name);
    }
    */

    if (mode.requestRead())
    {
        if (!getFileSystem().hasCapability(Capability.RANDOM_ACCESS_READ))
        {
            throw new FileSystemException("vfs.provider/random-access-read-not-supported.error");
        }
        if (!isReadable())
        {
            throw new FileSystemException("vfs.provider/read-not-readable.error", name);
        }
    }

    if (mode.requestWrite())
    {
        if (!getFileSystem().hasCapability(Capability.RANDOM_ACCESS_WRITE))
        {
            throw new FileSystemException("vfs.provider/random-access-write-not-supported.error");
        }
        if (!isWriteable())
        {
            throw new FileSystemException("vfs.provider/write-read-only.error", name);
        }
    }

    // Get the raw input stream
    try
    {
        return doGetRandomAccessContent(mode);
    }
    catch (final Exception exc)
    {
        throw new FileSystemException("vfs.provider/random-access.error", name, exc);
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:51,代码来源:AbstractFileObject.java


示例20: testRandomRead

import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
/**
 * Read a file
 */
public void testRandomRead() throws Exception
{
    FileObject file = null;
    try
    {
        file = getReadFolder().resolveFile("file1.txt");
        RandomAccessContent ra = file.getContent().getRandomAccessContent(RandomAccessMode.READ);

        // read first byte
        byte c = ra.readByte();
        assertEquals(c, TEST_DATA.charAt(0));
        assertEquals("fp", ra.getFilePointer(), 1);

        // start at pos 4
        ra.seek(3);
        c = ra.readByte();
        assertEquals(c, TEST_DATA.charAt(3));
        assertEquals("fp", ra.getFilePointer(), 4);

        c = ra.readByte();
        assertEquals(c, TEST_DATA.charAt(4));
        assertEquals("fp", ra.getFilePointer(), 5);

        // restart at pos 4
        ra.seek(3);
        c = ra.readByte();
        assertEquals(c, TEST_DATA.charAt(3));
        assertEquals("fp", ra.getFilePointer(), 4);

        c = ra.readByte();
        assertEquals(c, TEST_DATA.charAt(4));
        assertEquals("fp", ra.getFilePointer(), 5);

        // advance to pos 11
        ra.seek(10);
        c = ra.readByte();
        assertEquals(c, TEST_DATA.charAt(10));
        assertEquals("fp", ra.getFilePointer(), 11);

        c = ra.readByte();
        assertEquals(c, TEST_DATA.charAt(11));
        assertEquals("fp", ra.getFilePointer(), 12);
    }
    finally
    {
        if (file != null)
        {
            file.close();
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:55,代码来源:ProviderRandomReadTests.java



注:本文中的org.apache.commons.vfs2.util.RandomAccessMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Refreshable类代码示例发布时间:2022-05-22
下一篇:
Java BlockStemMelon类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap