Skip to content

Commit

Permalink
starts setup
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Apr 26, 2024
1 parent da6107c commit 3716a8e
Show file tree
Hide file tree
Showing 6 changed files with 5,536 additions and 5,383 deletions.
32 changes: 32 additions & 0 deletions src/main/java/org/myrobotlab/io/FileIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
package org.myrobotlab.io;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -1424,5 +1426,35 @@ public static String normalize(String dirPath) {
return dirPath.replace("\\", "/");
}
}

public static boolean isExecutableAvailable(String command) {
try {
// Attempt to execute the command
Process process = java.lang.Runtime.getRuntime().exec(command);

// Check the exit value of the process
// If the process has terminated correctly, the command is available
if (process.waitFor() == 0) {
return true;
}

// Read any errors from the attempted command
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}

return false;
} catch (IOException e) {
log.info("IOException: " + e.getMessage());
return false;
} catch (InterruptedException e) {
log.info("InterruptedException: " + e.getMessage());
return false;
}
}


}
Loading

0 comments on commit 3716a8e

Please sign in to comment.