IO { public static void eachLine( Reader reader, EachLine eachLine ) { try ( BufferedReader bufferedReader = new BufferedReader( reader ) ) { eachLine( bufferedReader, eachLine ); } catch ( Exception ex ) { Exceptions.handle( List.class, ex ); } }  static FileSystem zipFileSystem( URI fileJarURI ); static void println(); static void println(Object message); static void print(String message); static void print(Object message); static void puts(Object... messages); static void putl(Object... messages); static List<String> list( final Path path ); static List<Path> listPath( final Path path ); static List<String> listByGlob( final String path, final String glob ); static List<String> listByGlob( Path pathFromFileSystem, String glob ); static List<String> listByFileExtension( final String path, final String ext ); static List<String> listByFileExtension( final Path pathFromFileSystem, final String ext ); static List<String> listByFileExtensionRecursive( final String path, final String ext ); static List<String> listByFileExtensionRecursive( final Path pathFromFileSystem, final String ext ); static String readChild( Path parentDir, String childFileName ); static char[] readCharBuffer( Path path ); static String read( InputStream inputStream, Charset charset ); static String read( InputStream inputStream, String charset ); static String readCharBuffer( InputStream inputStream, Charset charset ); static String read( InputStream inputStream ); static char[] readCharBuffer( InputStream inputStream ); static CharBuf read( InputStream inputStream, CharBuf charBuf ); static CharBuf read( InputStream inputStream, CharBuf charBuf, Charset charset ); static CharBuf read( InputStream inputStream, CharBuf charBuf, Charset charset, int bufSize, char[] copyBuf ); static byte[] input( String fileName ); static byte[] input( InputStream inputStream ); static long copyLarge( Reader reader, Writer writer ); static long copyLarge( Reader reader, Writer writer, char[] buffer ); static String read( Reader input ); static CharBuf read( Reader input, CharBuf charBuf, final int bufSize, char[] copyBuffer ); static CharBuf read( Reader input, CharBuf charBuf ); static char[] readCharBuffer( Reader input ); static int copy( Reader input, Writer output ); static int copy( Reader input, Writer output, char[] copyBuf ); static char[] readCharBuffer( Reader reader, int size ); static String read( File file ); static List<String> readLines( Reader reader ); static void eachLine( Reader reader, EachLine eachLine ); static List<String> readLines( InputStream is ); static void eachLine( InputStream is, EachLine eachLine ); static List<String> readLines( BufferedReader reader ); static void eachLine( BufferedReader reader, EachLine eachLine ); static void eachLine( File file, EachLine eachLine ); static List<String> readLines( File file ); static List<String> readLines( final String location ); static URI createURI( final String path ); static void eachLine( final String location, final EachLine eachLine ); static String getWindowsPathIfNeeded( String path ); static String read( final Path path ); static String readPath( final Path path ); static String read( final String location ); static String readFromFileSchema( URI uri ); static Path uriToPath( URI uri ); static String read( String location, URI uri ); static void write( OutputStream out, String content, Charset charset ); static void writeChild( Path parentDir, String childFileName, String childContents ); static Path createChildDirectory( Path parentDir, String childDir ); static Path createDirectory( Path dir ); static Path createDirectory( String dir ); static FileSystem fileSystem(); static Path path( String path, String... more ); static Path path( Path path, String... more ); static void write( Path file, String contents ); static void write( String file, String contents ); static void output( String file, byte[] bytes ); static void output( Path file, byte[] bytes ); static void write( String file, byte[] contents ); static void write( Path file, byte[] contents ); static void write( OutputStream out, String content ); static void writeNoClose( OutputStream out, String content ); static InputStream inputStream( String resource ); static List<String> list( final String path ); static List<Path> paths( final String path ); static List<Path> pathsByExt( final String path, String ext ); static List<Path> paths( final Path path ); static List<String> listByExt( final String path, String ext ); static void delete(Path path); static void createDirectories(Path path); static void delete(String path); static void createDirectories(String path); static Path path( String location ); static boolean exists(Path path ); static boolean exists(String path ); static void move(Path source, Path target); static void pressEnterKey(String pressEnterKeyMessage); static void pressEnterKey(); static String gets(); final static Charset DEFAULT_CHARSET; final static String FILE_SCHEMA; final static String JAR_SCHEMA; final static String JAR_FILE_SCHEMA; static ConvertToPathFunction convertToPathFunction; }
@Test public void testReadEachLineHttp() throws Exception { HttpServer server = HttpServer.create( new InetSocketAddress( 9668 ), 0 ); server.createContext( "/test", new MyHandler() ); server.setExecutor( null ); server.start(); Thread.sleep( 10 ); IO.eachLine( "http: new IO.EachLine() { @Override public boolean line( String line, int index ) { if ( index == 0 ) { assertEquals( "line 1", line ); } else if ( index == 3 ) { assertEquals( "grapes", line ); } return true; } } ); }
@Test public void testReadEachLineReader() throws Exception { File testDir = new File( "src/test/resources/" ); File testFile = new File( testDir, "testfile.txt" ); IO.eachLine( new FileReader( testFile ), new IO.EachLine() { @Override public boolean line( String line, int index ) { if ( index == 0 ) { assertEquals( "line 1", line ); } else if ( index == 3 ) { assertEquals( "grapes", line ); } return true; } } ); }
@Test public void testReadEachLineInputStream() throws Exception { File testDir = new File( "src/test/resources" ); File testFile = new File( testDir, "testfile.txt" ); IO.eachLine( new FileInputStream( testFile ), new IO.EachLine() { @Override public boolean line( String line, int index ) { if ( index == 0 ) { assertEquals( "line 1", line ); } else if ( index == 3 ) { assertEquals( "grapes", line ); } return true; } } ); }