Good afternoon, there is a desire to unload into the specified folder .exe from the jar resources and, in principle, I did it, but somehow the “crutch” problem was at the beginning that the method

getResourceAsStream(Sp/Sp.txt) 

I didn’t find the required file which was located in the folder that was in the root of the package with the classes. Next, I put this file to classes without a folder and changed the extension to .txt and about the miracle it worked this way

 InputStream in = Main.class.getResourceAsStream("Sp.txt"); System.out.println(in); DataInputStream din = new DataInputStream(in); FileOutputStream outF = new FileOutputStream("C://Users//Desktop/resources/Ton/Sp/Sp.exe//"); 

But now this file also needs to upload files with the extension .dll as well as .ico but remove this method does not work.

    1 answer 1

    getResourceAsStream requires an absolute path (that is, starting with / ) so the correct version will be getResourceAsStream("/Sp/Sp.txt")