I
iksrazal
Hi all,
I have to do multiple file reads to get unordered data. What I have
works but is slow:
try {
/** unordered data, require seeks */
RandomAccessFile raf_bsc = new
RandomAccessFile(myFile,"r");
String btsm_id = null;
while ((line = raf_bsc.readLine()) != null) {
if (line.indexOf("SEARCH DATA:") == -1) {
continue;
}
pointer_bsc = raf_bsc.getFilePointer();
Scanner sc = new Scanner(line);
while (sc.hasNext()) {
sc.findInLine(".+BTSM
\\d+).*");
MatchResult result = sc.match();
btsm_id = result.group(1);
}
sc.close();
... call method to do multple file reads with seek(0)
and btsm_id
raf_bsc.seek(pointer_bsc);
}
} catch(Exception ex) { ex.printStackTrace(); }
Basically I just need:
1) seek(long);
2) Be able to run a regex on a line.
How can I do #1 and #2 in memory, via MappedByteBuffer/ByteBuffer ?
iksrazal
I have to do multiple file reads to get unordered data. What I have
works but is slow:
try {
/** unordered data, require seeks */
RandomAccessFile raf_bsc = new
RandomAccessFile(myFile,"r");
String btsm_id = null;
while ((line = raf_bsc.readLine()) != null) {
if (line.indexOf("SEARCH DATA:") == -1) {
continue;
}
pointer_bsc = raf_bsc.getFilePointer();
Scanner sc = new Scanner(line);
while (sc.hasNext()) {
sc.findInLine(".+BTSM
MatchResult result = sc.match();
btsm_id = result.group(1);
}
sc.close();
... call method to do multple file reads with seek(0)
and btsm_id
raf_bsc.seek(pointer_bsc);
}
} catch(Exception ex) { ex.printStackTrace(); }
Basically I just need:
1) seek(long);
2) Be able to run a regex on a line.
How can I do #1 and #2 in memory, via MappedByteBuffer/ByteBuffer ?
iksrazal