I understand your issue, I would drop down a code which should help you find the solution.
#   Configuration configuration = new Configuration();
#   FileSystem hdfs = FileSystem.get( new URI( "hdfs://localhost:54310" ), configuration );
#   Path file = new Path("hdfs://localhost:54310/s2013/batch/table.html");
#   if ( hdfs.exists( file )) { hdfs.delete( file, true ); } 
#   OutputStream os = hdfs.create( file,
#      new Progressable() {
#          public void progress() {
#              out.println("...bytes written: [ "+bytesWritten+" ]");
#          } });
#   BufferedWriter br = new BufferedWriter( new OutputStreamWriter( os, "UTF-8" ) );
#   br.write("Hello World");
#   br.close();
#   hdfs.close();
This code should help it.