title: How do i write a file to my classpath(resource folder) in spring boot?
body: <p>I'm trying to write an serialized object file to my class path which will be later used for read purpose. I have written the below code, </p>
  
  <pre><code>FileOutputStream fos = new FileOutputStream("src/main/resources/ListOfIotcontentObjects");
  ObjectOutputStream oos = new ObjectOutputStream(fos);
  oos.writeObject(fileList);
  </code></pre>
  
  <p>So while building the project with <code>mvn clean package</code> its creating the executable .jar without any exception, but when i tried to run the .jar it's saying <code>(The system cannot find the path specified)</code></p>
  
  <p>I don't understand what's going wrong here and how i can make it work ? thanks in advance.</p>
  
  <p><strong>Edit 1</strong>: To write/create the file in resource folder i have tried the below code which is throwing <code>NullPointerException</code>.</p>
  
  <pre><code>        ArrayList&lt;DevicesPOJO&gt; employees = new ArrayList&lt;&gt;();    
          employees.add(new DevicesPOJO(100, 1001, "Shaik", "Nasir", 12233456));
          employees.add(new DevicesPOJO(101, 1002, "Shaik", "Nasir", 12233654));
          employees.add(new DevicesPOJO(102, 1003, "Shaik", "Nasir", 12233465));
  
  
          ClassLoader classLoader = TestApplication.class.getClass().getClassLoader(); 
          File file = new File(classLoader.getResource("./ListOfIotcontentObjects").getFile());
          System.out.println(file.getPath());
          FileOutputStream fos = new FileOutputStream(file);
          ObjectOutputStream oos = new ObjectOutputStream(fos);
          oos.writeObject(employees);
          System.out.println("Success...");
  </code></pre>
  
  <p>Can anyone help me with this exception ?</p>