@SuppressWarnings("deprecation") @Test public void testMultiByteBreak() throws Exception { System.out.println("testMultiByteBreak() Default charset: "+Charset.defaultCharset().displayName()); final long delay = 50; final File origin = new File(this.getClass().getResource("/test-file-utf8.bin").toURI()); final File file = new File(getTestDirectory(), "testMultiByteBreak.txt"); createFile(file, 0); final TestTailerListener listener = new TestTailerListener(); final String osname = System.getProperty("os.name"); final boolean isWindows = osname.startsWith("Windows"); final Charset charsetUTF8 = Charsets.UTF_8; tailer = new Tailer(file, charsetUTF8, listener, delay, false, isWindows, 4096); final Thread thread = new Thread(tailer); thread.start(); Writer out = new OutputStreamWriter(new FileOutputStream(file), charsetUTF8); BufferedReader reader = null; try{ List<String> lines = new ArrayList<String>(); reader = new BufferedReader(new InputStreamReader(new FileInputStream(origin), charsetUTF8)); String line; while((line = reader.readLine()) != null){ out.write(line); out.write("\n"); lines.add(line); } out.close(); final long testDelayMillis = delay * 10; TestUtils.sleep(testDelayMillis); List<String> tailerlines = listener.getLines(); assertEquals("line count",lines.size(),tailerlines.size()); for(int i = 0,len = lines.size();i<len;i++){ final String expected = lines.get(i); final String actual = tailerlines.get(i); if (!expected.equals(actual)) { fail("Line: " + i + "\nExp: (" + expected.length() + ") " + expected + "\nAct: (" + actual.length() + ") "+ actual); } } }finally{ tailer.stop(); IOUtils.closeQuietly(reader); IOUtils.closeQuietly(out); } }
private void stop(final Exception e) { listener.handle(e); stop(); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener);  Tailer(final File file, final TailerListener listener, final long delayMillis);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final int bufSize);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen, final int bufSize);  Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis,
                  final boolean end, final boolean reOpen
            , final int bufSize); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener);  Tailer(final File file, final TailerListener listener, final long delayMillis);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final int bufSize);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen, final int bufSize);  Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis,
                  final boolean end, final boolean reOpen
            , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen,
            final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener,
                                final long delayMillis, final boolean end, final boolean reOpen
            ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop(); }
Tailer implements Runnable { private void stop(final Exception e) { listener.handle(e); stop(); } Tailer(final File file, final TailerListener listener);  Tailer(final File file, final TailerListener listener, final long delayMillis);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final int bufSize);  Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end,
                  final boolean reOpen, final int bufSize);  Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis,
                  final boolean end, final boolean reOpen
            , final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen,
            final int bufSize); static Tailer create(final File file, final Charset charset, final TailerListener listener,
                                final long delayMillis, final boolean end, final boolean reOpen
            ,final int bufSize); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end); static Tailer create(final File file, final TailerListener listener, final long delayMillis,
                                final boolean end, final boolean reOpen); static Tailer create(final File file, final TailerListener listener, final long delayMillis); static Tailer create(final File file, final TailerListener listener); File getFile(); long getDelay(); void run(); void stop();  }