Mercurial Hosting > luan
diff src/goodjava/lucene/logging/LogFile.java @ 1480:1f41e5921090
input buffering
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 24 Apr 2020 14:32:20 -0600 |
parents | 7d145095cc0b |
children | 3cff066f3bbc |
line wrap: on
line diff
--- a/src/goodjava/lucene/logging/LogFile.java Fri Apr 24 10:52:54 2020 -0600 +++ b/src/goodjava/lucene/logging/LogFile.java Fri Apr 24 14:32:20 2020 -0600 @@ -6,7 +6,7 @@ import java.io.DataOutputStream; import java.io.RandomAccessFile; import java.io.ByteArrayOutputStream; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; import java.io.IOException; import java.util.List; import java.util.Map; @@ -24,6 +24,8 @@ import org.apache.lucene.util.BytesRef; import goodjava.logging.Logger; import goodjava.logging.LoggerFactory; +import goodjava.io.LimitedInputStream; +import goodjava.io.BufferedInputStream; public class LogFile { @@ -72,10 +74,12 @@ } public LogInputStream input() throws IOException { - byte[] a = new byte[(int)end - 8]; - raf.seek(8L); - raf.readFully(a); - return newLogInputStream(new ByteArrayInputStream(a)); + InputStream in = new FileInputStream(file); + in = new LimitedInputStream(in,end); + in = new BufferedInputStream(in); + LogInputStream lis = newLogInputStream(in); + lis.readLong(); // skip end + return lis; } protected LogInputStream newLogInputStream(InputStream in) {