I want to simply assign the file name "database.txt" to a string type variable say "fname". What is the code for it for java. I want to use relative file destinations.
Asked
Active
Viewed 846 times
-3
-
1`String fname = "database.txt"` ? – Seelenvirtuose Oct 21 '17 at 17:07
-
Have you Googled at least once? – Shubhendu Pramanik Oct 21 '17 at 17:08
-
omg stop -1ing just because the question is basic – Henley n Oct 21 '17 at 17:18
-
Possible duplicate of [Global variables in Java](https://stackoverflow.com/questions/4646577/global-variables-in-java) – Optional Oct 21 '17 at 17:40
1 Answers
0
try something like this :
File file = new File("your/path"); String str = file.getName();
Henley n
- 3,593
- 2
- 10
- 13