import java.io.FileInputStream;
import java.io.IOException;
public class ReadExe {
public static void main(String[] args) {
File file = new File("path/to/your/executable.exe");
try (FileInputStream fis = new FileInputStream(file)) {
int byteRead;
while ((byteRead = fis.read()) != -1) {
System.out.print(Integer.toHexString(byteRead & 0xFF) + " "); // Print as hex
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.File;
import java.io.IOException;
public class ExecuteExe {
public static void main(String[] args) {
String exePath = "path/to/your/executable.exe";
try {
Process process = Runtime.getRuntime().exec(exePath);
process.waitFor(); // Wait for the process to complete
System.out.println("Executable finished with exit code: " + process.exitValue());
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment