If you wrote that code, you should be able to very simply modify it - it's a less complicated task.
And since that code is copy'n'pasted from here:
Spark WordCount example - Java Developer Zone[
^] I don't believe a word of what you are saying.
And neither will your teacher when you hand it in ...
Homework is set for a reason: to let you develop a skill using what has been covered in lessons. Cheating doesn't do that, and it means that subsequent tasks become harder and harder because you haven't learn how to do the basics, or developed any skill at all.
Just like riding a bicycle, you can watch people riding them all you like, the first dozen times you try it for real you are going to fall off because you don't have the reflexes built up to balance it properly - you haven't got the skills you need to cycle yet.
And I for one, really, really do not like being lied to.