Skip to content

Commit 2c576a3

Browse files
committed
Add round method and lines from resource
1 parent f55b851 commit 2c576a3

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

.classpath

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
</classpathentry>
1515
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
1616
<attributes>
17+
<attribute name="test" value="true"/>
1718
<attribute name="optional" value="true"/>
1819
<attribute name="maven.pomderived" value="true"/>
19-
<attribute name="test" value="true"/>
2020
</attributes>
2121
</classpathentry>
2222
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
2323
<attributes>
24-
<attribute name="maven.pomderived" value="true"/>
2524
<attribute name="test" value="true"/>
25+
<attribute name="maven.pomderived" value="true"/>
2626
<attribute name="optional" value="true"/>
2727
</attributes>
2828
</classpathentry>
2929
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25">
3030
<attributes>
31+
<attribute name="module" value="true"/>
3132
<attribute name="maven.pomderived" value="true"/>
3233
</attributes>
3334
</classpathentry>
@@ -36,5 +37,6 @@
3637
<attribute name="maven.pomderived" value="true"/>
3738
</attributes>
3839
</classpathentry>
40+
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/6"/>
3941
<classpathentry kind="output" path="target/classes"/>
4042
</classpath>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>io.github.emays</groupId>
77
<artifactId>parent</artifactId>
8-
<version>0.0.7</version>
8+
<version>0.0.8-SNAPSHOT</version>
99
<relativePath />
1010
</parent>
1111

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.mays.util;
2+
3+
import java.math.BigDecimal;
4+
import java.math.RoundingMode;
5+
6+
public class MathUtil {
7+
8+
private MathUtil() {
9+
}
10+
11+
public static BigDecimal round(double value, int scale) {
12+
return new BigDecimal(value).setScale(scale, RoundingMode.HALF_UP);
13+
}
14+
15+
}

src/main/java/com/mays/util/Util.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.mays.util;
22

3+
import java.io.BufferedReader;
34
import java.io.IOException;
5+
import java.io.InputStream;
6+
import java.io.InputStreamReader;
47
import java.io.PrintWriter;
58
import java.nio.file.Files;
69
import 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

Comments
 (0)