Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
Expand All @@ -36,5 +36,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/6"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.github.emays</groupId>
<artifactId>parent</artifactId>
<version>0.0.7</version>
<version>0.0.8</version>
<relativePath />
</parent>

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/mays/util/MathUtil.java
Original file line number Diff line number Diff line change
@@ -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);
}

}
14 changes: 13 additions & 1 deletion src/main/java/com/mays/util/Util.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<String> lines = Files.lines(Paths.get(in_file)).map(line -> line.replace(fr, to));
Files.write(Paths.get(out_file), iterable(lines));
}
Expand All @@ -45,6 +49,14 @@ public static Iterable<String> lines(Path path) throws IOException {
return iterable(Files.lines(path));
}

public static Stream<String> 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<String> fields) {
return delimitedString("\t", fields);
}
Expand Down