diff options
-rw-r--r-- | blasearch.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/blasearch.java b/blasearch.java index f774600..2cd4032 100644 --- a/blasearch.java +++ b/blasearch.java @@ -32,13 +32,25 @@ public class blasearch { { String query = ""; - // Incorporate all args in search - for(int i=0; i<args.length; i++){ - args[i] = args[i].replace(' ','+'); - query = query + args[i] + "+"; + /* Build query from query or arguments, depending on whether + arguments were given. */ + if (args.length == 0) { + try { + BufferedReader br = + new BufferedReader(new InputStreamReader(System.in)); + query = br.readLine(); + } catch (Exception e) { + System.err.println("Error:" + e.getMessage()); + System.exit(1); + } + } else { + for (int i = 0; i < args.length; i++) { + query += args[i]; + } } - // Remove trailing + - query = query.substring(0, query.length()-1); + + // Change all ' ' to '+' + query = query.replaceAll(" ", "+"); String[] parts = null; //URL which provides XML response |