Path ftp directory with spaces

Asked

Viewed 211 times

1

Good morning guys, I’m having trouble getting to a subdirectory on ftp, the name of one of the Ubdirectories has space, and with that I can not advance. I’m doing a project on Java. Could someone please help ?

ftp.changeWorkingDirectory("/Premium%202.0/Executaveis/Producao");

in this case when I copy the path %2 is inserted, then only ftp root is listed.

1 answer

0

You can try using the backslash \ to escape space, just as it is done when browsing linux directories. Do so:

ftp.changeWorkingDirectory("/Premium\\ 2.0/Executaveis/Producao");

You need to use two backslashes because java uses the backslash as an escape character.

  • worked as follows following the idea of Andre Gusmao ftp.changeWorkingDirectory("/Premium " + "2.0/Executaveis/Producao"); thus arrived in the production directory and listed the files within it.

  • ftp.changeWorkingDirectory("/Premium 2.0/Executaveis/Producao"); @Fabioaragão, not only works using space?

  • No, it gives error in netbeans: illegal scape Character and hence not saved, but accepting the netbeans option to fix, it does so and then saved and works by actually listing the files that are within this directory

  • @Fabioaragão, I edited my answer, now will not give compilation error.

  • did not work because the result is that it displays the files at the root and not in the directory in question

Browser other questions tagged

You are not signed in. Login or sign up in order to post.