Skip to content

Commit

Permalink
CLDR-15323 Fix fileutilities for Windows (#1729)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth authored Feb 3, 2022
1 parent b9e3880 commit 0789429
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ public static PrintWriter openUTF8Writer(File dir, String filename) throws IOExc
}

public static PrintWriter openWriter(File dir, String filename, Charset encoding) throws IOException {
File file = new File(dir, filename);
File file;
if (dir.equals("")) {
file = new File(filename);
} else {
file = new File(dir, filename);
}
if (SHOW_FILES && log != null) {
log.println("Creating File: " + getNormalizedPathString(file));
}
Expand Down Expand Up @@ -271,7 +276,11 @@ public static BufferedReader openFile(Class<?> class1, String file, Charset char

public static BufferedReader openFile(String directory, String file, Charset charset) {
try {
return new BufferedReader(new InputStreamReader(new FileInputStream(new File(directory, file)), charset));
if (directory.equals("")) {
return new BufferedReader(new InputStreamReader(new FileInputStream(new File(file)), charset));
} else {
return new BufferedReader(new InputStreamReader(new FileInputStream(new File(file, directory)), charset));
}
} catch (FileNotFoundException e) {
throw new ICUUncheckedIOException(e); // handle dang'd checked exception
}
Expand Down

0 comments on commit 0789429

Please sign in to comment.