Some alternatives to/for null checking.

This commit is contained in:
Michael Bayne
2018-08-30 14:09:24 -07:00
parent 038b8351ac
commit 8988aa82b4
3 changed files with 14 additions and 22 deletions
@@ -196,8 +196,8 @@ public class GetdownApp
protected void showDocument (String url) { protected void showDocument (String url) {
String[] cmdarray; String[] cmdarray;
if (RunAnywhere.isWindows()) { if (RunAnywhere.isWindows()) {
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name", "");
if (osName != null && (osName.indexOf("9") != -1 || osName.indexOf("Me") != -1)) { if (osName.indexOf("9") != -1 || osName.indexOf("Me") != -1) {
cmdarray = new String[] { cmdarray = new String[] {
"command.com", "/c", "start", "\"" + url + "\"" }; "command.com", "/c", "start", "\"" + url + "\"" };
} else { } else {
@@ -188,19 +188,16 @@ public class FileUtil
public static void walkTree (File root, Visitor visitor) public static void walkTree (File root, Visitor visitor)
{ {
File[] children = root.listFiles(); File[] children = root.listFiles();
if (children != null) { if (children == null) return;
Deque<File> stack = new ArrayDeque<>(Arrays.asList(children)); Deque<File> stack = new ArrayDeque<>(Arrays.asList(children));
while (!stack.isEmpty()) { while (!stack.isEmpty()) {
File currentFile = stack.pop(); File currentFile = stack.pop();
if (currentFile.exists()) { if (currentFile.exists()) {
visitor.visit(currentFile); visitor.visit(currentFile);
if (currentFile.isDirectory()) { File[] currentChildren = currentFile.listFiles();
File[] currentChildren = currentFile.listFiles(); if (currentChildren != null) {
if (currentChildren != null) { for (File file : currentChildren) {
for (File file : currentChildren) { stack.push(file);
stack.push(file);
}
}
} }
} }
} }
@@ -182,13 +182,8 @@ public class LaunchUtil
*/ */
public static boolean mustMonitorChildren () public static boolean mustMonitorChildren ()
{ {
String osname = System.getProperty("os.name"); String osname = System.getProperty("os.name", "").toLowerCase();
if (osname != null) { return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1);
osname = osname.toLowerCase();
return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1);
} else {
return false;
}
} }
/** /**