java command line space & escape character parser for Runtime.exec



Hi all,

I'm trying to execute a string of command using Runtime.exec. This
string may contain space or other meta-charcters which has been
escaped. Does anyone know any tools out there does the parsing and
possibly put them into an array or in a collection for me?

i.e. on the extreme side, here is a possible string (assuming user
always uses double slashes)
"\"C:\\My Test\\my test batch.bat" argA \"arg B\" \"arg\ C\" \"arg\tD\"
\"arg \/E\""

This may or may not be an everyday usecase, but it does happens.

Does anyone out there know how java.exe parse the command line string
to a string array which then used by "static void main(String[] args)"?

Thank you guys!
Jimmy

.



Relevant Pages

  • Re: Creation of DSN
    ... Build a text string from the input data. ... rather execute the string that was just built. ... script file has been processed. ... > I'm using directly a Command, ...
    (microsoft.public.vb.database.ado)
  • TIP #185: Null Handling
    ... nulls, and command modifications for manipulating them. ... Tcl deals with strings, the universal medium for representing data. ... is know and it is an empty string, but if a respondent forgets to give ...
    (comp.lang.tcl)
  • Re: SET IDENTITY_INSERT tablename ON problem
    ... Try to combine all statements into one string and then execute them in one ... A couple of my tables use identity columns. ... > The next command is to insert the data but I get an error that says I ...
    (microsoft.public.vb.database.ado)
  • Re: Determine how Word was launched
    ... inspect the command line used to launch Word. ... Private Declare Function GetCommandLineA Lib "kernel32" As Long ... Public Function GetCommandLineAs String ... Dim lngCmdLinePtr As Long ...
    (microsoft.public.office.developer.vba)
  • Re: Class.getMethod in classs static initializer block
    ... I just wanted to add that I had some similar code for a "command line server" project. ... static private final boolean DEBUG = true; ... {public ReturnCode runCommand(String s) ... public ReturnCode parseLine(String line) ...
    (comp.lang.java.programmer)