Configuration conf = new Configuration();
// local FS must be raw in order to be Syncable
conf.set("fs.file.impl", "org.apache.hadoop.fs.RawLocalFileSystem");
Path path = new Path(fileURI);
FileSystem fs = path.getFileSystem(conf); // get FS with our conf cached
CompressionCodecFactory factory = new CompressionCodecFactory(conf);
HDFSCompressedDataStream writer = new HDFSCompressedDataStream();
FlumeFormatter fmt = new HDFSTextFormatter();
writer.open(fileURI, factory.getCodec(new Path(fileURI)),
SequenceFile.CompressionType.BLOCK, fmt);
String body = "yarf!";
Event evt = EventBuilder.withBody(body, Charsets.UTF_8);
writer.append(evt, fmt);
writer.sync();