Question: Write a complete Java program in a file called FilterSort.java that reads all the tokens from a file named data.txt that is to be found

 Write a complete Java program in a file called FilterSort.java that

Write a complete Java program in a file called FilterSort.java that reads all the tokens from a file named data.txt that is to be found in the same directory as the running program. The program should ignore all tokens that cannot be read as an integer and read only the ones that can. After reading all of the integers, the program should print all the integers back to the screen, one per line, from the smallest to the largest. For example if data.txt contains 10 Sfive 10 1.5 2 2.0 20 Then your program should print to the screen 10 10 20 Your program should not prompt the user for anything and should print nothing except the sorted list of integers (if there are no integers your program should print nothing). If the file does not exist, then your program should instead print exactly "File not found" and exit. Your program should start by allocating an array of size 8 and fill it with the first 8 tokens. On the ninth token, it should replace the array with one of size 16 and copy all the integers already read. On the 17th token, it should replace the array with one of size 32 and copy all the integers already read. Etc. Since this doubling the size of an array is a repeated operation that is easily factored into a coherent chunk, you should write a method that performs this task. Also, be sure you read the textbook about the Arrays class and the java documentation about the static method Arrays.sort(a, fromIndex, toIndex) You should not write your own sorting algorithm

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!