in src/main/java/org/apache/datasketches/Files.java [508:527]
public static int stringToFileNIO(final String text, final String fileName,
final Charset charset) {
checkFileName(fileName);
final File file = new File(fileName);
int bytes = 0;
if (!file.isFile()) {
try {
file.createNewFile();
} catch (final IOException e) {
throw new RuntimeException("Cannot create new file: " + fileName + LS + e);
}
try (FileChannel fc = openRandomAccessFile(file, "rw").getChannel()) {
bytes = write(text, fc, 0L, charset);
} catch (final IOException e) {
throw new RuntimeException("Cannot create File Channel: " + fileName + LS + e);
}
}
return bytes;
}