Results 1 to 9 of 9
  1. #1
    mac's Avatar
    mac
    mac is offline Member
    Join Date
    Dec 2009
    Location
    St. Petersburg, Russia
    Posts
    81
    Rep Power
    0

    Default String, quotes and args

    Say i pass a
    Java Code:
    blah
    parameter to your Java application, what's the args[0]?
    blah

    Now lets say i pass you
    Java Code:
    "blah"
    parameter to you. Now what's the args[0]?
    blah again

    How about this? I would like to not have my Strings translated ... In a second case, i actually want to have args[0] to be
    Java Code:
    "blah"
    Literally. No translation. I want my quotes back. How can do that?

    Thanks guys

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I think that it's more an OS issue than a Java issue (though I could be wrong). Any thoughts from any others?

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Ah, how about if you use \"blah\" as your command-line parameter?

  4. #4
    mac's Avatar
    mac
    mac is offline Member
    Join Date
    Dec 2009
    Location
    St. Petersburg, Russia
    Posts
    81
    Rep Power
    0

    Default

    Well, that's cheating - user input cannot be controlled

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mac View Post
    Well, that's cheating - user input cannot be controlled
    Call it what you will, but it's the only way you'll get to keep your quotes.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,953
    Rep Power
    19

    Default

    Also, I really wouldn't expect a non-tech savvy person running a Java program from the command line...:)

  7. #7
    mac's Avatar
    mac
    mac is offline Member
    Join Date
    Dec 2009
    Location
    St. Petersburg, Russia
    Posts
    81
    Rep Power
    0

    Default

    Doesn't have to be straight command line. Jsp with a fancy ui can provide a text box where user will type what he pleases including double quotes

    Question remains unanswered - how to take command line arguments literally? If "a" is passed I want to deal with "a", not a

    Thx

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,953
    Rep Power
    19

    Default

    That's been answered.
    The user has to escape the quotes.

    Command line arguments are not JSP text boxes, or JTextFields (for Swing).

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mac View Post
    Doesn't have to be straight command line. Jsp with a fancy ui can provide a text box where user will type what he pleases including double quotes
    Completely different problem here.

    Question remains unanswered - how to take command line arguments literally? If "a" is passed I want to deal with "a", not a
    The only answer for the original problem has been given. Feel free to re-ask it though as many times as you like.

Similar Threads

  1. Why can't we write main without String args[]
    By shailender in forum New To Java
    Replies: 6
    Last Post: 06-17-2013, 09:28 AM
  2. Public static void main (String args[])
    By arefeh in forum New To Java
    Replies: 12
    Last Post: 01-28-2010, 11:58 AM
  3. What does String args[] stand for?
    By Addez in forum New To Java
    Replies: 7
    Last Post: 08-19-2009, 10:24 AM
  4. Replies: 6
    Last Post: 05-19-2009, 12:22 PM
  5. [SOLVED] ReadLine(String fmt,Object... args) of Console class
    By Pooja Deshpande in forum New To Java
    Replies: 4
    Last Post: 04-25-2008, 05:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •