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) {
String[] cmdarray;
if (RunAnywhere.isWindows()) {
String osName = System.getProperty("os.name");
if (osName != null && (osName.indexOf("9") != -1 || osName.indexOf("Me") != -1)) {
String osName = System.getProperty("os.name", "");
if (osName.indexOf("9") != -1 || osName.indexOf("Me") != -1) {
cmdarray = new String[] {
"command.com", "/c", "start", "\"" + url + "\"" };
} else {
@@ -188,19 +188,16 @@ public class FileUtil
public static void walkTree (File root, Visitor visitor)
{
File[] children = root.listFiles();
if (children != null) {
Deque<File> stack = new ArrayDeque<>(Arrays.asList(children));
while (!stack.isEmpty()) {
File currentFile = stack.pop();
if (currentFile.exists()) {
visitor.visit(currentFile);
if (currentFile.isDirectory()) {
File[] currentChildren = currentFile.listFiles();
if (currentChildren != null) {
for (File file : currentChildren) {
stack.push(file);
}
}
if (children == null) return;
Deque<File> stack = new ArrayDeque<>(Arrays.asList(children));
while (!stack.isEmpty()) {
File currentFile = stack.pop();
if (currentFile.exists()) {
visitor.visit(currentFile);
File[] currentChildren = currentFile.listFiles();
if (currentChildren != null) {
for (File file : currentChildren) {
stack.push(file);
}
}
}
@@ -182,13 +182,8 @@ public class LaunchUtil
*/
public static boolean mustMonitorChildren ()
{
String osname = System.getProperty("os.name");
if (osname != null) {
osname = osname.toLowerCase();
return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1);
} else {
return false;
}
String osname = System.getProperty("os.name", "").toLowerCase();
return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1);
}
/**