Write a program named JavaOrNot

We will write a program named JavaOrNot.java to test that all files in our current directory have a .java extension. Any filename that does NOT have a .java extension will be logged in an external file. Step 1: Create an exception class called NotJavaException, designed to be thrown when a filename NOT ending in .java is encountered during processing. If a filename is encountered that doesn’t fit that description (last 5 characters do not equal “.java”), the exception is thrown.Note: First you want to check If the filename is greater than 5  then grab the last 5 characters using String’s substring method storing this substring in it’s own String variable.Hint: Last character in a String is stringName.length( ) – 1Step 2: catch and handle the exception if it is thrown.  Handle the exception (inside the catch) by printing the filename (really just a String) to an external file named nonJava.txt  Note: You will need an outer try/catch to handle the opening of the external file.Step 3: See driver program below to test the exception.Run your program in a directory with some .java files and some non-.java files (example: testit.txt is non-.java file)Note: add the code for writing out to a file last.  For debugging, have your output go to the console so you can see what is happening within your program.Warning: Don’t forget to close() file so output is flushed. NO need for a finally clause.InputAll input comes from the files in the current directory. Here is the code to read files from the current directory “.”:import java.io.*; public class JavaOrNot { public static void main(String [] args) { File folder = new File(“.”); //dot is current directory File[] listOfFiles = folder.listFiles(); //we now have array of File objects String name = “”; for (File file : listOfFiles) { #check it’s a file not subdirectory if (file.isFile()) { name = file.getName(); //each file name is a String System.out.println(name); } } } }

20% OFF on your first order








Let’s Get Started

Team with top experts around the globe to succeed in learning


How it works

If you are looking for the best essay writing services for cheap, then you have come to the right place. Essaytab.com specializes in custom academic papers for all levels of students. From high school students to college graduates and undergraduates, all the way up to university students at master’s degree and even doctoral levels.

Place an order

Fill out the order form. Attach any custom instructions.

Make Payment

Pay online safely with major platforms.

Writing Process

We’ll assign your paper to the most suitable writer & editor.

Get your Order

Once complete, we’ll send the paper to your email.