diff --git a/.classpath b/.classpath index f2cab10..8252b41 100644 --- a/.classpath +++ b/.classpath @@ -14,15 +14,15 @@ + - - + @@ -36,5 +36,6 @@ + diff --git a/pom.xml b/pom.xml index 80164cb..ebabb23 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.github.emays parent - 0.0.7 + 0.0.8 diff --git a/src/main/java/com/mays/util/MathUtil.java b/src/main/java/com/mays/util/MathUtil.java new file mode 100644 index 0000000..e0f08a0 --- /dev/null +++ b/src/main/java/com/mays/util/MathUtil.java @@ -0,0 +1,15 @@ +package com.mays.util; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +public class MathUtil { + + private MathUtil() { + } + + public static BigDecimal round(double value, int scale) { + return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP); + } + +} diff --git a/src/main/java/com/mays/util/Util.java b/src/main/java/com/mays/util/Util.java index 11aad84..6dca70f 100644 --- a/src/main/java/com/mays/util/Util.java +++ b/src/main/java/com/mays/util/Util.java @@ -1,6 +1,10 @@ package com.mays.util; +import java.io.BufferedReader; +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; @@ -23,7 +27,7 @@ public static PrintWriter newPrintWriter(Path path) throws IOException { return new PrintWriter(Files.newBufferedWriter(path)); } - public static void trFile(String fr, String to, String in_file, String out_file) throws IOException { + public static void trFile(String fr, String to, String in_file, String out_file) throws IOException { Stream lines = Files.lines(Paths.get(in_file)).map(line -> line.replace(fr, to)); Files.write(Paths.get(out_file), iterable(lines)); } @@ -45,6 +49,14 @@ public static Iterable lines(Path path) throws IOException { return iterable(Files.lines(path)); } + public static Stream getResourceLines(String resource) throws FileNotFoundException { + InputStream stream = Util.class.getResourceAsStream(resource); + if (stream == null) + throw new FileNotFoundException(resource); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + return reader.lines(); + } + public static String tabDelimitedString(List fields) { return delimitedString("\t", fields); }