Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do i show the filename.type instead of the entire file path?

975744Nov 22 2012 — edited Nov 22 2012
How do i show the filename.type instead of the entire file path?
I want it to show "ProgramSetup.exe" instead of "C:/Program Files/Oracle/JavaFX/ProgramSetup.exe"

I have created a JavaFX program with the help of my manager
below are the code
			File file = fileChooser.showOpenDialog(Admin.mainStage);
			if (file != null) {
				textFiles.setText(file.getAbsolutePath());
				String absolutePath = file.getAbsolutePath();
				//String fileName = new File(absolutePath).getName();
the reason i put the last line as // because it has error on that line....
if i remove the last line, it will display but with the full path....

i search through google and the guide on many forums aren't clear to me.....some said there are 2 ways but i tried and it is not working, atleast for me...maybe i left out something or what....can anyone help me on this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 20 2012
Added on Nov 22 2012
5 comments
215 views