Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime.getRuntime().exec

 
Nagamani Srivastava
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to open a file using Runtime.getRuntime().exec("cmd /C" + filepath). this doesn't work if I have brackets in the file name.
Say C:\My Workspace\Registry\ERPReports\ALV_Demo_Program_(Output_Simplest_version).csv

Can anyone help??

thanks & regards
Nagamani
 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try escaping (add a slash \ before special characters) the braces?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15369
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

You posted your question in the forum about the SCJA exam, but it looks like your question doesn't have anything to do with SCJA. I will move it to a more appropriate forum for you.

Please choose the appropriate forum when you post a question on JavaRanch.
 
Nagamani Srivastava
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if we add escape char before (, then my path string becomes invalid.

 
Paul Michael
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nagamani Srivastava wrote:if we add escape char before (, then my path string becomes invalid.



Ah sorry for that. Did you also try working on a directory name without spaces?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic