Created
June 1, 2017 09:54
-
-
Save njlr/f0c24f765aae1e2ab9a1f8e4be6ef48c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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