Skip to content

Instantly share code, notes, and snippets.

@njlr
Created June 1, 2017 09:54
Show Gist options
  • Save njlr/f0c24f765aae1e2ab9a1f8e4be6ef48c to your computer and use it in GitHub Desktop.
Save njlr/f0c24f765aae1e2ab9a1f8e4be6ef48c to your computer and use it in GitHub Desktop.
import com.google.common.base.Charsets;
import com.google.common.io.MoreFiles;
import com.google.common.io.ByteSink;
import java.nio.file.Path;
public final class GuavaFileUtils {
private GuavaFileUtils() {
}
public static String readFile(final Path path) throws IOException {
return MoreFiles.asCharSource(path, Charsets.UTF_8).read();
}
public static void writeFile(final Path path) throws IOException {
final ByteSink sink = MoreFiles.asByteSink(path);
sink.write(content.getBytes());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment