@Override public void seek(long pos) throws IOException { this.rac.seek(pos); }
@Override public void seek(final long pos) throws IOException { content.seek(pos); }
@Override public void seek(final long pos) throws IOException { content.seek(pos); }
@Override public void seek(final long pos) throws IOException { this.rac.seek(pos); }
@Override public void seek(final long pos) throws IOException { content.seek(pos); }
public void setPosition(long pos) throws IOException { rac.seek(pos); }
@Override public void seek(final long pos) throws IOException { content.seek(pos); }
public void setPosition(long pos) throws IOException { rac.seek(pos); }
FileObject fo = VFS.getManager().resolveFile("ftp://..."); RandomAccessContent rac = fo.getContent().getRandomAccessContent(RandomAccessMode.READ); rac.seek(4711);
private long readLines(RandomAccessContent reader) throws IOException, FileServerConnectorException { long pos = reader.getFilePointer(); long rePos = pos; List<Byte> list = new ArrayList<>(); int num; int lines = 0; boolean throttled = false; for (; ((num = read(reader, inbuf)) != -1) && !throttled; pos = reader.getFilePointer()) { for (int i = 0; (i < num) && !throttled; ++i) { byte ch = this.inbuf[i]; if (ch == 10) { Byte[] line = new Byte[list.size()]; line = list.toArray(line); EventListener.fileUpdated(line, messageProcessor, serviceName); lines++; list.clear(); rePos = pos + (long) i + 1L; } else { list.add(ch); } if (maxLinesPerPoll != -1 && (lines > maxLinesPerPoll) && ch == 10) { throttled = true; } } } reader.seek(rePos); return rePos; }
public InputStream newStream(final long start, final long end) { try { final long newFileStart = this.fileStart + start; final long newFileEnd = end < 0 ? this.fileEnd : this.fileStart + end; final RandomAccessContent rac = fo.getContent().getRandomAccessContent(RandomAccessMode.READ); rac.seek(newFileStart); return new SharedRandomContentInputStream(createdStreams, fo, newFileStart, newFileEnd, rac.getInputStream()); } catch (final IOException e) { throw new RuntimeException(e); } }
public InputStream newStream(long start, long end) { try { long newFileStart = this.fileStart+start; long newFileEnd = end<0?this.fileEnd:this.fileStart+end; RandomAccessContent rac = fo.getContent().getRandomAccessContent(RandomAccessMode.READ); rac.seek(newFileStart); return new SharedRandomContentInputStream( createdStreams, fo, newFileStart, newFileEnd, rac.getInputStream()); } catch (IOException e) { throw new RuntimeException(e); } }
ra.seek(3); ra.writeByte(TEST_DATA.charAt(3)); ra.writeByte(TEST_DATA.charAt(4)); ra.seek(3); ra.writeByte(TEST_DATA.charAt(7)); ra.writeByte(TEST_DATA.charAt(8)); ra.seek(10); ra.writeByte(TEST_DATA.charAt(10)); ra.writeByte(TEST_DATA.charAt(11)); ra.seek(0); assertEquals(ra.readByte(), TEST_DATA.charAt(0)); ra.seek(3); assertEquals(ra.readByte(), TEST_DATA.charAt(7)); assertEquals(ra.readByte(), TEST_DATA.charAt(8)); ra.seek(10); assertEquals(ra.readByte(), TEST_DATA.charAt(10)); assertEquals(ra.readByte(), TEST_DATA.charAt(11));
ra.seek(3); ra.writeByte(TEST_DATA.charAt(3)); ra.writeByte(TEST_DATA.charAt(4)); ra.seek(3); ra.writeByte(TEST_DATA.charAt(7)); ra.writeByte(TEST_DATA.charAt(8)); ra.seek(10); ra.writeByte(TEST_DATA.charAt(10)); ra.writeByte(TEST_DATA.charAt(11)); ra.seek(0); assertEquals(ra.readByte(), TEST_DATA.charAt(0)); ra.seek(3); assertEquals(ra.readByte(), TEST_DATA.charAt(7)); assertEquals(ra.readByte(), TEST_DATA.charAt(8)); ra.seek(10); assertEquals(ra.readByte(), TEST_DATA.charAt(10)); assertEquals(ra.readByte(), TEST_DATA.charAt(11));
public LoadingInfo(FileObject fileObject, boolean tailing, OpenMode openMode) throws IOException { this.fileObject = fileObject; this.tailing = tailing; friendlyUrl = fileObject.getName().getFriendlyURI(); fileObject.refresh(); InputStream inputStream = fileObject.getContent().getInputStream(); byte[] probe = loadProbe(inputStream, 10000); gzipped = checkIfIsGzipped(probe, probe.length); inputStreamBufferedStart = gzipped ? ungzip(probe) : probe; if (openMode == FROM_START || gzipped) { PushbackInputStream pushBackInputStream = new PushbackInputStream(inputStream, probe.length + 1); // +1 to support empty files pushBackInputStream.unread(probe); observableInputStreamImpl = new ObservableInputStreamImpl(pushBackInputStream); contentInputStream = gzipped ? new GZIPInputStream(observableInputStreamImpl) : observableInputStreamImpl; } else { RandomAccessContent randomAccessContent = fileObject.getContent().getRandomAccessContent(READ); randomAccessContent.seek(randomAccessContent.length()); observableInputStreamImpl = new ObservableInputStreamImpl(randomAccessContent.getInputStream()); contentInputStream = observableInputStreamImpl; } if (fileObject.getType().hasContent()) { lastFileSize = fileObject.getContent().getSize(); } }
public void reloadIfFileSizeChanged() throws IOException { fileObject.refresh(); long lastFileSize = this.lastFileSize; long currentSize = fileObject.getContent().getSize(); if (currentSize > lastFileSize) { observableInputStreamImpl.close(); RandomAccessContent randomAccessContent = fileObject.getContent().getRandomAccessContent(READ); randomAccessContent.seek(lastFileSize); this.lastFileSize = currentSize; observableInputStreamImpl = new ObservableInputStreamImpl(randomAccessContent.getInputStream(), lastFileSize); if (gzipped) { contentInputStream = new GZIPInputStream(observableInputStreamImpl); } else { contentInputStream = observableInputStreamImpl; } } else if (currentSize < lastFileSize) { observableInputStreamImpl.close(); InputStream inputStream = fileObject.getContent().getInputStream(); observableInputStreamImpl = new ObservableInputStreamImpl(inputStream, 0); if (gzipped) { contentInputStream = new GZIPInputStream(observableInputStreamImpl); } else { contentInputStream = observableInputStreamImpl; } this.lastFileSize = fileObject.getContent().getSize(); } }
position = this.startPosition == -1 ? this.fileObject.getContent().getSize() : startPosition; currentTime = System.currentTimeMillis(); reader.seek(position); } catch (FileSystemException e) { throw new FileServerConnectorException(