Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. RandomAccessFile file = new RandomAccessFile(document, "r");
  2.             StringBuffer currentSeq = new StringBuffer();
  3.             char last = '0';
  4.             boolean add = false;
  5.             if (offset == 0) {
  6.                 add = true;
  7.             }
  8.             else {
  9.                 file.skipBytes(offset-1);
  10.                 last = (char) file.readByte();
  11.                 if (sep.indexOf(last) != -1) {
  12.                     add = true;
  13.                 }
  14.             }
  15.             for (int i = 0; i < toRead; i++) {
  16.                 last = (char) file.readByte();
  17.                 if (sep.indexOf(last) != -1) {
  18.                     add = true;
  19.                 }
  20.                 if (add) {
  21.                     currentSeq.append(last);
  22.                 }
  23.             }
  24.             int pos = toRead + offset;
  25.             while (sep.indexOf(last) == -1 && pos < fileSize) {
  26.                 pos++;
  27.                 last = (char) file.readByte();
  28.                 currentSeq.append(last);
  29.             }
  30.             String sentence = currentSeq.toString();
  31.             file.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement