For this we should use the Hadoop FileSystem API rather than a java file writer.