Java Utililty Methods File Attribute

List of utility methods to do File Attribute

Description

The list of methods to do File Attribute are organized into topic(s).

Method

FilejavaExecutable(File jre)
java Executable
if (!jre.isDirectory()) {
    return null;
File bin = new File(jre, "bin");
if (bin != null && bin.isDirectory()) {
    String os = System.getProperty("os.name").toLowerCase();
    String exeName = os.contains("win") ? "java.exe" : "java";
    return new File(bin, exeName);
...
ProcesslaunchExecutable(String executable, List args, Preferences preferences)
launch Executable
List<String> command = new ArrayList<>();
try {
    if (preferences.get("commandMono", "mono").isEmpty()) {
        command.add(
                new File(preferences.get("basedir", null), "working").getAbsolutePath() + "/" + executable);
    } else {
        command.add(preferences.get("commandMono", "mono"));
        command.add(executable);
...
StringmakeCurrentDirectoryThatOfExecutable(String executable)
Set the directory to that of the executable, such that "c:\some\dir\file.exe" will set to "c:\some\dir\"
String curDir, newDir;
curDir = getCurrentDirectory();
newDir = new File(executable).getParent();
setCurrentDirectory(newDir);
return (curDir);
voidmakeExecutable(File file)
Give execute privilege to a UNIX file Written by: S.
String[] cmds2 = { "chmod", "-R", "+rx", file.getAbsolutePath() };
Process child1 = Runtime.getRuntime().exec(cmds2);
child1.waitFor();
booleanmakeExecutable(File file)
Attempt to make the given file executable.
if (file.setExecutable(true, false)) {
    return true;
return file.setExecutable(true, true);
voidmakeExecutable(File file)
Attempt to make a file executable.
Process p = Runtime.getRuntime().exec(new String[] { "chmod", "ug+rx", file.getAbsolutePath() });
try {
    copy(p.getErrorStream(), new ByteArrayOutputStream());
} finally {
    try {
        if (p.waitFor() != 0) {
            throw new IOException("Failed to set execute permission. Return code " + p.exitValue() + ".");
    } catch (InterruptedException e) {
voidmakeExecutable(File file)
Mark a file as executable.
if (File.separatorChar == '/')
    try {
        if (Runtime.getRuntime().exec(new String[] { "chmod", "+x", file.getPath() }).waitFor() != 0)
            throw new IOException("chmod +x " + file + " failed");
    } catch (InterruptedException e) {
        throw new IOException("Interrupted waiting for chmod +x " + file);
voidmakeExecutable(File target)
Gives the target or it's contents executable permissions.
if (target.isFile()) {
    target.setExecutable(true);
} else {
    for (File file : target.listFiles()) {
        makeExecutable(file);
voidmakeExecutable(String path)
make Executable
if (path == null) {
    return;
File file = new File(path);
if (file.exists() && !file.canExecute()) {
    file.setExecutable(true);
voidparallel(ExecutorService executor, Collection> tasks)
parallel
List<Future<?>> futures = tasks.stream().map(task -> executor.submit(task)).collect(Collectors.toList());
for (Future<?> future : futures) {
    try {
        future.get();
    } catch (CancellationException | InterruptedException e) {
        cancel(futures);
        throw e;
    } catch (ExecutionException e) {
...