Created
September 22, 2023 15:40
-
-
Save xonixx/cb0944413f7ccc22f2b295b392ecef83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Process process = Runtime.getRuntime().exec(new String[]{"ls", "-l", fullPath}); | |
process.waitFor(); | |
java.util.Scanner s = new java.util.Scanner(process.getInputStream()).useDelimiter("\\A"); | |
String result = s.hasNext() ? s.next() : ""; | |
System.out.println(result); | |
s = new java.util.Scanner(process.getErrorStream()).useDelimiter("\\A"); | |
result = s.hasNext() ? s.next() : ""; | |
System.out.println(result); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment