public static String readFile(Path parentDir,String name) throws IOException {
  if (parentDir == null) {
    return null;
  }
  Path path=parentDir.resolve(name);
  try (InputStream in=Files.newInputStream(path)){
    return new String(ByteStreams.toByteArray(in),ENC);
  }
 catch (  NoSuchFileException e) {
    return null;
  }
catch (  IOException e) {
    throw new IOException("Error reading " + path,e);
  }
}

public static String readFile ( Path parentDir , String name ) throws IOException { if ( parentDir == null ) { return null ; } Path path = parentDir . resolve ( name ) ; try ( InputStream in = Files . newInputStream ( path ) ) { return new String ( ByteStreams . toByteArray ( in ) , ENC ) ; } catch ( NoSuchFileException e ) { return null ; } catch ( IOException e ) { throw new IOException ( "Error reading " + path , e ) ; } }
read a utf - 8 text file from the local drive .
