-
Deprecated MethodsMethodDescriptionPrefer
asCharSink(to, charset, FileWriteMode.APPEND).write(from). This method is scheduled to be removed in October 2019.PreferasCharSource(from, charset).copyTo(to).For Android users, see the Data and File Storage overview to select an appropriate temporary directory (perhapscontext.getCacheDir()), and create your own directory under that. (For example, you might usenew File(context.getCacheDir(), "directoryname").mkdir(), or, if you need an arbitrary number of temporary directories, you might have to generate multiple directory names in a loop untilmkdir()returnstrue.) For developers on Java 7 or later, usejava.nio.file.Files#createTempDirectory, transforming it to aFileusingjava.nio.file.Path#toFile() toFile()if needed. To restrict permissions as this method does, passPosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwx------"))to your call tocreateTempDirectory.PreferasByteSource(file).hash(hashFunction).PreferasByteSource(file).read(processor).PreferasCharSource(file, charset).readFirstLine().PreferasCharSource(file, charset).readLines(callback).PreferasCharSource(file, charset).read().PreferasCharSink(to, charset).write(from).The semantics ofwriteBytes(String s)are considered dangerous. Please use#writeUTF(String s),#writeChars(String s)or another write method instead.
write(s.getBytes(StandardCharsets.UTF_8)).