Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RandomAccessFile file = new RandomAccessFile(document, "r");
- StringBuffer currentSeq = new StringBuffer();
- char last = '0';
- boolean add = false;
- if (offset == 0) {
- add = true;
- }
- else {
- file.skipBytes(offset-1);
- last = (char) file.readByte();
- if (sep.indexOf(last) != -1) {
- add = true;
- }
- }
- for (int i = 0; i < toRead; i++) {
- last = (char) file.readByte();
- if (sep.indexOf(last) != -1) {
- add = true;
- }
- if (add) {
- currentSeq.append(last);
- }
- }
- int pos = toRead + offset;
- while (sep.indexOf(last) == -1 && pos < fileSize) {
- pos++;
- last = (char) file.readByte();
- currentSeq.append(last);
- }
- String sentence = currentSeq.toString();
- file.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement