I have filepath and title of the file. Is there a way to create a File object with these informations ?
Something like this:
String a = new String("/directory/name.txt");
String b = new String("This is the title");
File f = new File(a,b);
I have filepath and title of the file. Is there a way to create a File object with these informations ?
Something like this:
String a = new String("/directory/name.txt");
String b = new String("This is the title");
File f = new File(a,b);
File
has a constructor which receives a string of the location of that file on the computer.
File f = new File("path\\to\\your\\file");
Assuming that title of the file
means its name, you can use
f.renameTo("newName");
to rename your file.
Unrelated to files: You don't need to initialize a String
.
just write:
String a = "/directory/name.txt";
to create a string.