public boolean hasNext() { File dir = file.getParentFile(); for (File f : dir.listFiles()) if (matchesSequence(f)) return true; return false; }
/** * @see stream.urls.Connection#disconnect() */ @Override public void disconnect() throws IOException { if (seqFileStream != null) { seqFileStream.close(); seqFileStream = null; } } }
public Long bytesRead() { return this.getCurrentOffset(); }
openNextFile(); if (hasNext()) { openNextFile(); } else {
public static void main(String[] args) throws Exception { File input = new File("/tmp/test.log"); SequentialFileInputStream f = new SequentialFileInputStream(input, false); PrintStream out = new PrintStream(new FileOutputStream(new File( input.getAbsolutePath() + "-complete"))); byte[] buf = new byte[1024]; int read = 0; int written = 0; do { if (f.available() > 0) buf = new byte[Math.min(1024, f.available())]; read = f.read(buf); if (read >= 0) { written += read; out.write(buf, 0, read); out.flush(); } log.debug("{} bytes written", written); } while (read > 0); } }
/** * @see stream.urls.Connection#connect() */ @Override public InputStream connect() throws IOException { boolean removeAfterRead = "true".equalsIgnoreCase(url.getParameters() .get("remove")) || "true".equalsIgnoreCase(url.getParameters().get( "removeAfterRead")); String pattern = ".*"; if (url.getParameters().containsKey("pattern")) { pattern = url.getParameters().get("pattern"); } File file = new File(url.getPath()); seqFileStream = new SequentialFileInputStream(file, pattern, removeAfterRead); if (url.getParameters().containsKey("maxWaitingTime")) { seqFileStream.setMaxWaitingTime(new Long(url.getParameters().get( "maxWaitingTime"))); } return seqFileStream; }
/** * @see stream.urls.Connection#connect() */ @Override public InputStream connect() throws IOException { boolean removeAfterRead = "true".equalsIgnoreCase(url.getParameters() .get("remove")); String pattern = ".*"; if (url.getParameters().containsKey("pattern")) { pattern = url.getParameters().get("pattern"); } File file = new File(url.getPath()); seqFileStream = new SequentialFileInputStream(file, pattern, removeAfterRead); return seqFileStream; }
openNextFile(); if (hasNext()) { openNextFile(); } else {
while (reader == null) { log.trace("reader is null, opening next file..."); openNextFile(); return null; if (line == null && hasNext()) { log.trace("Switching to next file..."); openNextFile(); } else { log.trace("Waiting for lines to be appended to {}", current);
/** * This method checks if there exists a next file in the sequence. * * @return <code>true</code> if a new file exists, which may indicate that * the current file is finished. */ protected boolean hasNext() { File dir = file.getParentFile(); if (file.isDirectory()) dir = file; for (File f : dir.listFiles()) if (matchesSequence(f) && !f.equals(current)) return true; return false; }
/** * @see stream.urls.Connection#disconnect() */ @Override public void disconnect() throws IOException { if (seqFileStream != null) { seqFileStream.close(); seqFileStream = null; } } }
/** * This method checks if there exists a next file in the sequence. * * @return <code>true</code> if a new file exists, which may indicate that * the current file is finished. */ protected boolean hasNext() { File dir = file.getParentFile(); if (file.isDirectory()) dir = file; for (File f : dir.listFiles()) if (matchesSequence(f) && !f.equals(current)) return true; return false; }
if (matchesSequence(f) && !finished.contains(f)) {
if (matchesSequence(f) && !finished.contains(f)) {
File dir = file.getParentFile(); for (File f : dir.listFiles()) { if (matchesSequence(f) && this.startTime <= f.lastModified()) { log.debug( " File {} (last-modified-at {}) is considered a candidate to proceed",