Hello folks,
Not sure what the problem is here. When I run this code it creates directories just fine. If I hit the "cancel" button, however, it creates a directory called "null". When I attempt to check the string for null, I get a NullPointerException. Any help is greatly appreciated.
public void makeTables() throws IOException{ String dirPath = "data/tendtables/"; String tname = (String)JOptionPane.showInputDialog( "Enter the name of the new strain:"); // Canceled? if (tname.equals(null)) return; // Check if directory already exists File tendTableDir = new File(dirPath + tname); if (tendTableDir.exists()){ JOptionPane.showMessageDialog(null, "Strain already created!"); }else{ // Create the directory tendTableDir.mkdir();