Use File instead of String

This commit is contained in:
AsamK 2020-12-25 23:07:36 +01:00
parent 5c754b6f5d
commit 22f19c4067
7 changed files with 61 additions and 54 deletions

View file

@ -46,11 +46,6 @@ public class IOUtils {
return baos.toByteArray();
}
public static void createPrivateDirectories(String directoryPath) throws IOException {
final File file = new File(directoryPath);
createPrivateDirectories(file);
}
public static void createPrivateDirectories(File file) throws IOException {
if (file.exists()) {
return;
@ -65,8 +60,8 @@ public class IOUtils {
}
}
public static void createPrivateFile(String path) throws IOException {
final Path file = new File(path).toPath();
public static void createPrivateFile(File path) throws IOException {
final Path file = path.toPath();
try {
Set<PosixFilePermission> perms = EnumSet.of(OWNER_READ, OWNER_WRITE);
Files.createFile(file, PosixFilePermissions.asFileAttribute(perms));
@ -75,13 +70,13 @@ public class IOUtils {
}
}
public static String getDataHomeDir() {
public static File getDataHomeDir() {
String dataHome = System.getenv("XDG_DATA_HOME");
if (dataHome != null) {
return dataHome;
return new File(dataHome);
}
return System.getProperty("user.home") + "/.local/share";
return new File(new File(System.getProperty("user.home"), ".local"), "share");
}
public static void copyStreamToFile(InputStream input, File outputFile) throws IOException {