Using the createNewFile method and the delete method of the File class, I successfully create files from my program. But after the compilation process, an annoying warning message appears. My question is how to remove these warning messages without using @SUPPRESSWARNIGN . Because when I check my code, I see likely error warnings caused by these two methods. Yes, when using @SuppressWarning warnings and likely error messages go away.
I donβt know if this is related to the Java version, but in any case I use Java 8. I did research on this issue, could not find anything on the Internet. I saw how people on the Internet used these 2 methods in the same way as I used. Maybe they ignored the warning messages. But I dont want.
Here is my code:
private void createAFile() throws IOException { String outputFileName = getFileName(); String outputPathName = getFilePath(); String fullOutputPath = outputPathName + "/" + outputFileName; output = new File(fullOutputPath); if(output.exists()){ output.delete();
Warnings:
Warning: (79, 20) The result of "File.delete ()" is ignored. Warning: (84, 16) The result "File.createNewFile ()" is ignored.
thanks
source share