I was struck in a weird problem , for which i found out the cause of reason , after lot of debugging . I have a Java program which i am executing in Linux environment through a bash script .
This is my simple bash script , which accepts a String .
#!/bin/bash java -cp com.QuoteTester $1
The issue is that the command line argument can be with Spaces or Without spaces . For example it can be either
Apple Inc. 2013 Jul 05 395.00 Call OR Apple
As per my code it is this way
public static void main(String[] args) { String symbol = args[0]; if (symbol.trim().contains(" ")) // Option { } else // Stock { }
So the issue is that , when i am trying to execute it this way
./quotetester Apple Inc. 2013 Jul 05 395.00 Call
its only always going to the else condition
that is Stock .
Is there anyway i can resolve this ??