Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing string as arg to main

 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to pass in a long string that is xml format as an arg to the main. But I get errors that say "Encountered EOF after : ""

My string looks like this:



How do I fix this problem?
 
Henry Wong
author
Marshal
Pie
Posts: 21114
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Passing in a long strings is not a problem -- I have read megabyte strings from files and passed it to methods, and it works fine.

I am guessing that you are using a string literal, and forgot to escape the quotes.

Henry
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you want to pass it as an argument? longer pieces of text (especially if it's xml) should be read from a file and you only provide the lookup point as an argument.
 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a good idea!
 
Miklos Szeles
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if it is a platform independent solution but on Windows it works:
Put the whole text between "" and put a \ in front of every " in the text:

"# @prefix wwtts: <http://localhost/ontologies/wwtts.owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
. :i1 a wwtts:Incident . :i1 wwtts:incidVessel :v2 .:i1 wwtts:incidOccurRegion \"INDONESIA\" . :v2 wwtts:vesselFlag \"US\" . :v2
wwtts:vesselName \"BIG BERTHA\" . :v2 wwtts:vesselWeight 2953 .:p3 a wwtts:Alarm .:p3 wwtts:featurerawtext \"alarms\" .
#"
 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is strange. I thought I tried it with the "\" in front of the ". This time it worked.
I am actually passing the string to a web service from a client. But now I am not sure
how to extract the string returned.

I am getting a getStringResponse object which when I do a toString does not seem to
return a string although it is supposed to. I will post it to the web services group, unless you
have any suggestions.

Thanks,

Sonia
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic