java - Creating file with empty title -
i tried creating file empty title or space , worked cannot find file in directory. not delete or rename file.
file dir1 = new file("dir1"); dir1.mkdir(); file file1 = new file(dir1, ""); file1.createnewfile();
system.out.println(file1.exists());
returns true if execute file1.delete()
or file1.renameto(...)
since passing empty string child, file1
same dir1
, you're doing file1
happening directory created.
here sample:
public static void main(string[] args) { file directory = new file("/home/test"); directory.mkdir(); file file = new file(directory, ""); system.out.println(file.exists()); system.out.println(file.getabsolutepath()); system.out.println(directory.getabsolutepath()); file.delete(); system.out.println(directory.exists()); system.out.println(file.exists()); }
output:
true /home/test /home/test false false
Comments
Post a Comment