0

I am working on a Java code which runs AutoIT script. I am trying to attach documents on one website using AutoIT. For that, I am referring to MS Access database and fetching the path from one table to get the documents. I am passing the path to AutoIt like this:

Runtime.getRuntime().exec((ProjectPath+AutoITConfig.getProperty("AutoITExeFilePath")+" "+rs.getString(1)));

where " rs.getString(1) " contains the path for the documents.

The problem I am facing here is that the path contains spaces in between, which doesn't allow AutoIT to copy full path. I searched and found that I have to put the path inside quotes. But I am missing out something and not able to apply it in my code. I tried putting quotes around rs.getString(1) but didn't work out. I need help on the same.

Thanks in Advance.

Andreas
  • 5,393
  • 9
  • 44
  • 53
Deep
  • 11
  • 4
  • you could story the String returned by `rs.getString(1)` modify it the way you have to and then append it to the Property call. – L.Spillner Mar 14 '18 at 13:41
  • Try string.replace(" ", "\ ") that is the space escape for terminals – Marcos Vasconcelos Mar 14 '18 at 13:42
  • Or try `Runtime.getRuntime().exec((ProjectPath+AutoITConfig.getProperty("AutoITExeFilePath")+" \""+rs.getString(1) + "\""));` – Ben Mar 14 '18 at 13:48
  • Thanks for reply @MarcosVasconcelos . Actually the path is **D:\BAC files\Doc Folder\MemoBill.pdf**. If I replace spaces with " \ " then it will become **D:\BAC\files\Doc\Folder\MemoBill.pdf**. It won't solve the problem. Is my understanding correct? – Deep Mar 14 '18 at 13:51
  • It's is not simply "\" it is "\ " note the space, its a escape for spaces in file names, anyway.. i now pretty sure it is the opposite bar "/ " (note the space) – Marcos Vasconcelos Mar 14 '18 at 13:54

0 Answers0