I have a swing code. In which I will select a file and I want to pass that file to a method as a string. how to do it? Please give me a simple solution.This code should be in java
Ok I got the answer just follow this answer
Reading a txt file in a Java GUI gui/13667222#13667222
It depends, do you want the name of the file or the whole path…
File#getName()will return just the name of the file, without the path where asFile#getPath()will return the path and nameTen seconds reading the API docs would have given you the answer 😉