Question: Create a Java program that analyzes a program and produces the output into another file. The program must retrieve the path to the .java file.

Create a Java program that analyzes a program and produces the output into another file. The program must retrieve the path to the .java file. Once the path to the file is found the program must figure out the length of the longest line is in the program. For example, working with a program called MainFile.java. Once it figures out the longest line in the code it will put the output into MainFile.java.stats and it will be located in the same directory. It doesn't matter what the contents of the .java file is as long as the output is correct in the .java.stats file. You can use your own .java files and folders to figure this program out. You must use List lines = Files.readAllLines(filePath, Charset.defaultCharset()); iterate through the list of strings. And you must use void writeToFile( Path location, List toWrite ){ Files.write(location,toWrite,Charset.defaultCharset()); } to create the output text which will be MainFile.java.stats. Please use both of the bolded code exactly how it is to figure out this program. There is another solution on the website; however, it is not what I was looking for.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!