This discussion is archived
5 Replies Latest reply: Nov 22, 2012 7:34 AM by shakir.gusaroff RSS

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

975744 Newbie
Currently Being Moderated
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?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points