11package com .mays .util ;
22
3+ import java .io .BufferedReader ;
34import java .io .IOException ;
5+ import java .io .InputStream ;
6+ import java .io .InputStreamReader ;
47import java .io .PrintWriter ;
58import java .nio .file .Files ;
69import java .nio .file .Path ;
@@ -23,7 +26,7 @@ public static PrintWriter newPrintWriter(Path path) throws IOException {
2326 return new PrintWriter (Files .newBufferedWriter (path ));
2427 }
2528
26- public static void trFile (String fr , String to , String in_file , String out_file ) throws IOException {
29+ public static void trFile (String fr , String to , String in_file , String out_file ) throws IOException {
2730 Stream <String > lines = Files .lines (Paths .get (in_file )).map (line -> line .replace (fr , to ));
2831 Files .write (Paths .get (out_file ), iterable (lines ));
2932 }
@@ -45,6 +48,12 @@ public static Iterable<String> lines(Path path) throws IOException {
4548 return iterable (Files .lines (path ));
4649 }
4750
51+ public static Stream <String > getResourceLines (String resource ) {
52+ InputStream stream = Util .class .getResourceAsStream (resource );
53+ BufferedReader reader = new BufferedReader (new InputStreamReader (stream ));
54+ return reader .lines ();
55+ }
56+
4857 public static String tabDelimitedString (List <String > fields ) {
4958 return delimitedString ("\t " , fields );
5059 }
0 commit comments