Create a java method "String copyFile(String filename)" that Reads the data from the…
- User
Create a java method "String copyFile(String filename)" that
Reads the data from the file one line at a time and saves it into an array. Asks the user to enter the name of a new file "Enter a new name for the file:" Writes the array of data into the new file, without writing any null values. returns the new filename Notes:
- Open your new file to check that the file has been properly created.
- You can assume that there are less than 100 items in the file.
- Make sure that the original file exists otherwise print an error message "File was not found"
For example:
Test Input Result String file2copy = "data.txt"; String newFile = copyFile(file2copy); testFileCopy(file2copy, newFile); datacopy.txt Enter a new name for the file:
- Assistant