When you executed your code earlier, you got the out & it is stored in the hdfs://localhost:9000/result directory.
Now when you are executing the code again, it is unable to delete that directory & write the result again.
Either you have to delete the directory & re-execute the word count program.
hdfs dfs -rm -r /result
or you have to change the output directory name(make it result1) .