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   import java.nio.file.StandardOpenOption;
8   
9   /**
10   * Implementation specific to Java SE 8 version.
11   */
12  abstract class BaseFileUtils
13  {
14      static String fileRead( Path path, String encoding ) throws IOException
15      {
16          byte[] bytes = Files.readAllBytes( path );
17          return encoding != null ? new String( bytes, encoding ) : new String( bytes );
18      }
19  
20      static void fileWrite( Path path, String encoding, String data, OpenOption... openOptions ) throws IOException
21      {
22          byte[] bytes = encoding != null ? data.getBytes( encoding ) : data.getBytes();
23          Files.write( path, bytes, openOptions );
24      }
25  }