public static FileSystem write(final FileSystem fs, final Path path,
      final byte[] bytes) throws IOException {

    Objects.requireNonNull(path);
    Objects.requireNonNull(bytes);

    try (FSDataOutputStream out = fs.createFile(path).overwrite(true).build()) {
      out.write(bytes);
    }

    return fs;
  }
@Test
  public void testWriteBytesFileContext() throws IOException {
    URI uri = tmp.toURI();
    Configuration conf = new Configuration();
    FileContext fc = FileContext.getFileContext(uri, conf);
    Path testPath = new Path(new Path(uri), "writebytes.out");

    byte[] write = new byte[] {0x00, 0x01, 0x02, 0x03};

    FileUtil.write(fc, testPath, write);

    byte[] read = FileUtils.readFileToByteArray(new File(testPath.toUri()));

    assertArrayEquals(write, read);
  }