本文整理汇总了Java中org.apache.commons.vfs2.util.RandomAccessMode类的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessMode类的具体用法?Java RandomAccessMode怎么用?Java RandomAccessMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RandomAccessMode类属于org.apache.commons.vfs2.util包,在下文中一共展示了RandomAccessMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例8: doGetRandomAccessContent
import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
return new HttpRandomAccessContent(this, mode);
}
示例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);
}
示例10: doGetRandomAccessContent
import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
return new LocalFileRandomAccessContent(file, mode);
}
示例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);
}
}
示例12: doGetRandomAccessContent
import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode)
throws Exception
{
return new RamFileRandomAccessContent(this, mode);
}
示例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();
}
};
}
示例14: doGetRandomAccessContent
import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception
{
return new FtpRandomAccessContent(this, mode);
}
示例15: doGetRandomAccessContent
import org.apache.commons.vfs2.util.RandomAccessMode; //导入依赖的package包/类
@Override
protected RandomAccessContent doGetRandomAccessContent(
final RandomAccessMode mode) throws Exception
{
return new SftpRandomAccessContent(this, mode);
}