dcsimg
Read a file from an offset
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Marc_Claustre
Posted On:   Thursday, October 31, 2002 12:46 AM

Hi, I'm trying to read a (text) file from an offset. Per example, I would read 30 bytes from the 150th byte of the (text) file. How can I do It ? I tryied it : int iTockenSize = 30; byte[] byData = new byte[iTockenSize]; FileInputStream fileInputStream = new FileInputStream(_fArcDir); fileInputStream.read (byData, _iOrigin, byData.length); String strToks = new String (byData); But it's not at all what I want. This code read the file form his begin and store the data in the "_iOrigin" th offset of the bytes' tab. I would read the file from the "_iOrigin&quo   More>>

Hi,
I'm trying to read a (text) file from an offset.
Per example, I would read 30 bytes from the 150th byte of the (text) file.
How can I do It ?


I tryied it :

			
int iTockenSize = 30;
byte[] byData = new byte[iTockenSize];
FileInputStream fileInputStream = new FileInputStream(_fArcDir);
fileInputStream.read (byData, _iOrigin, byData.length);
String strToks = new String (byData);


But it's not at all what I want. This code read the file form his begin and store the data in the "_iOrigin" th offset of the bytes' tab.

I would read the file from the "_iOrigin" th bytes and store it at the begin of the bytes' tab...


Thanks for previous replies...    <<Less

it's ok

Posted By:   Marc_Claustre  
Posted On:   Thursday, October 31, 2002 02:10 AM

I found alone :


int iTockenSize = 30;
byte[] byData = new byte[iTockenSize];
RandomAccessFile randomAccessFile = new RandomAccessFile(_fArcDir, "r");
randomAccessFile.seek(_iOrigin);
randomAccessFile.read(byData);
String strToks = new String (byData);
About | Sitemap | Contact