java - Reading files of different types in ByteBuffer -
in java application (fuse file system) need read types of files bytebuffer. did below:
public int read(final string path, final bytebuffer buffer, final long size, final long offset, final fileinfowrapper info) { path p = paths.get(path); seek { byte[] info = files.readallbytes(p); buffer.put(bytebuffer.wrap(data)); homecoming data.length; } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); }
but *.txt extensions files read correctly (i think because of less size, larger *.txt files not read correctly). rest of file types not correctly read.
these errors shown file type specific applications while opening files
it throws these errors while reading files other *.txt
severe: exception thrown: java.nio.bufferoverflowexception java.nio.directbytebuffer.put(directbytebuffer.java:357) java.nio.directbytebuffer.put(directbytebuffer.java:336) org.organization.upesh.firstmaven.sfs_360.read(sfs_360.java:132) net.fusejna.loggedfusefilesystem$27.invoke(loggedfusefilesystem.java:437) net.fusejna.loggedfusefilesystem$27.invoke(loggedfusefilesystem.java:433) net.fusejna.loggedfusefilesystem.log(loggedfusefilesystem.java:355) net.fusejna.loggedfusefilesystem.read(loggedfusefilesystem.java:432) net.fusejna.fusefilesystem._read(fusefilesystem.java:234) net.fusejna.structfuseoperations$23.callback(structfuseoperations.java:260) sun.reflect.generatedmethodaccessor8.invoke(unknown source) sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) java.lang.reflect.method.invoke(method.java:606) com.sun.jna.callbackreference$defaultcallbackproxy.invokecallback(callbackreference.java:455) com.sun.jna.callbackreference$defaultcallbackproxy.callback(callbackreference.java:485)
and reading process slow.
what right way read types of file correctly , @ speed.
p.s. whatever solution suggest, reading file bytebuffer must , must returns number of bytes transferred.
please read function signature of what you're trying implement.
public int read(final string path, final bytebuffer buffer, final long size, final long offset, final fileinfowrapper info)
as can see, there's size
, offset
argument there. function supposed read size
number of bytes file @ most, , supposed read them offset offset
file. function not supposed read everything. provided illustration filesystem shows how this.
java file-io
No comments:
Post a Comment