Skip to content

Commit f7eb1c7

Browse files
committed
Factor out method that accepts an InputStream
1 parent 7e55d9e commit f7eb1c7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/com/nordstrom/common/file/VolumeInfo.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.BufferedReader;
44
import java.io.File;
55
import java.io.IOException;
6+
import java.io.InputStream;
67
import java.io.InputStreamReader;
78
import java.util.HashMap;
89
import java.util.Map;
@@ -20,18 +21,21 @@ private VolumeInfo() {
2021
}
2122

2223
public static Map<String, VolumeProps> getVolumeProps() throws IOException {
23-
Map<String, VolumeProps> propsList = new HashMap<>();
24-
Pattern template = Pattern.compile("(.+) on (.+) type (.+) \\((.+)\\)");
25-
2624
Process mountProcess;
2725
if (IS_WINDOWS) {
2826
String[] cmd = {"sh", "-c", "mount | grep noumount"};
2927
mountProcess = Runtime.getRuntime().exec(cmd);
3028
} else {
3129
mountProcess = Runtime.getRuntime().exec("mount");
3230
}
31+
return getVolumeProps(mountProcess.getInputStream());
32+
}
33+
34+
public static Map<String, VolumeProps> getVolumeProps(InputStream is) throws IOException {
35+
Map<String, VolumeProps> propsList = new HashMap<>();
36+
Pattern template = Pattern.compile("(.+) on (.+) type (.+) \\((.+)\\)");
3337

34-
InputStreamReader isr = new InputStreamReader(mountProcess.getInputStream());
38+
InputStreamReader isr = new InputStreamReader(is);
3539
try(BufferedReader mountOutput = new BufferedReader(isr)) {
3640
String line;
3741
while(null != (line = mountOutput.readLine())) {

0 commit comments

Comments
 (0)