the Question is : Write a program that reads a String from the keyboard. The program then creates a file named: xx.txt (replace xx with the String that is read from keyboard)
How can I create a New File then rename it using the keyboard !!
I've tried this code but its not working !!
How can I create a New File then rename it using the keyboard !!
I've tried this code but its not working !!
public class Problem1 {
public static void main(String[] args) {
Scanner Read = new Scanner(System.in);
System.out.print("Enter a new name: ");
String newName = Read.next();
File file = new File ("xx.txt");
File newFile = new File (newName);
file.renameTo(newFile);
}
}