/*
* Svjatoslav Commons - shared library of common functionality.
* Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
* or later as published by the Free Software Foundation.
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
public class IOHelper {
return result;
}
+ public static String getFileContentsAsString(final File file)
+ throws FileNotFoundException, IOException {
+ try {
+ return new String(getFileContents(file), "UTF-8");
+ } catch (final UnsupportedEncodingException exception) {
+ throw new RuntimeException(exception);
+ }
+ }
+
/**
* Compares new file content with old file content. If content in equal,
* then leaves file as-is. If content differs, then overrides file with the
* new content.
- *
+ *
* @return <code>true</code> if file was overwritten.
*/
public static boolean overwriteFileIfContentDiffers(final File file,