If you are facing this problem while running a self-contained local application along with Spark
(i.e., after adding spark-assembly-x.x.x-hadoopx.x.x.jar or the Maven dependency to the project)
Then, a simpler solution would be to put winutils.exe in "C:\winutil\bin". You can add winutils.exe to the Hadoop home directory by adding the following line to the code:
System.setProperty("hadoop.home.dir", "c:\\\winutil\\\")
I hope this helps.