hey people!
im entirely new to java..i need a little bit of help with my assignment code..i want to use try catch. but i dont exactly know where to insert it.i keep getting errors when i insert it after "enter file name". but it says i cannot do that.i want to get a message saying the file isnt existing when wrong file names are inputted by the user.
/** * to back up txt files * @author (Dinushke Arthnayake) * @version (1.0.0) */ import java.util.Scanner; import javax.swing.*; import java.io.*; public class BackItUpTxt { public static void main(String agrs[]) throws IOException { String D_Play = "File does not exist!"; try { Scanner yeet1=new Scanner(System.in); System.out.println("Enter file that you want to backup:"); String yeet2=yeet1.nextLine(); System.out.println("Enter password to secure your backup:"); String yeet3=yeet1.nextLine(); for (int count =6; count > 0 && yeet3 != "acbt"; count--) { System.out.println("Wrong password. " + (count-1) + " attempts left.Enter password again:"); yeet3=yeet1.nextLine(); } Encrip.encrip(yeet3,yeet2); Backup.backup(yeet2); } catch(FileNotFoundException e){ JOptionPane.showMessageDialog (null,D_Play); System.exit(-1); } } }