View Javadoc
1   package org.codehaus.plexus.util;
2   
3   import java.io.IOException;
4   import java.nio.file.Files;
5   import java.nio.file.OpenOption;
6   import java.nio.file.Path;
7   
8   /**
9    * Implementation specific to Java SE 8 version.
10   */
11  abstract class BaseFileUtils {
12      static String fileRead(Path path, String encoding) throws IOException {
13          byte[] bytes = Files.readAllBytes(path);
14          return encoding != null ? new String(bytes, encoding) : new String(bytes);
15      }
16  
17      static void fileWrite(Path path, String encoding, String data, OpenOption... openOptions) throws IOException {
18          byte[] bytes = encoding != null ? data.getBytes(encoding) : data.getBytes();
19          Files.write(path, bytes, openOptions);
20      }
21  }