{"id":9117,"date":"2015-03-19T19:10:20","date_gmt":"2015-03-19T19:10:20","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=9117"},"modified":"2015-03-19T19:10:20","modified_gmt":"2015-03-19T19:10:20","slug":"the-java-scanner-example-the-linux-test-run","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/the-java-scanner-example-the-linux-test-run\/","title":{"rendered":"The Java Scanner example:  the Linux test run"},"content":{"rendered":"<h1>Continued coverage of the Java Scanner example, this time run on Linux.<\/h1>\n<p>To find the start of this thread, along with the source code of my Java Scanner example, see my post <a href=\"?p=9074\">here<\/a>.  I discuss a test run on Windows <a href=\"?p=9099\">here<\/a>.<\/p>\n<p>My Linux tests are run on Ubuntu 14.04; it uses the <strong>bash<\/strong> shell.  Here&#8217;s one of my command line calls:<br \/>\n<span style=\"font-family:monospace\"><br \/>\njava TryScanner $56.92 \\$56.92 26 here 54.e-3 678a a678 5.4f 5.4d<br \/>\n<\/span><br \/>\nThe result:<br \/>\n<span style=\"font-family:monospace\"><br \/>\nReadable number: 6.92  <span style=\"color:orange\">\/\/A little surprising?<\/span><br \/>\nNot a readable number: $56.92<br \/>\nReadable number: 26.0<br \/>\nNot a readable number: here<br \/>\nReadable number: 0.054<br \/>\nNot a readable number: 678a<br \/>\nNot a readable number: a678<br \/>\nNot a readable number: 5.4f<br \/>\nNot a readable number: 5.4d<br \/>\n<\/span><\/p>\n<p>Apparently, in <strong>bash<\/strong>, the Java Scanner program does interpret $56.92 as a readable number: 6.92.  If we escape the dollar sign like so:  <span style=\"font-family:monospace\">\\$56.92<\/span>, then the Java Scanner program sees the input as <span style=\"font-family:monospace\">$56.92<\/span>, which it deems an unreadable number.  Compared to the Windows test run yesterday, there are no other surprises in the results of this one.<\/p>\n<p>I&#8217;m no expert on operating systems, but I believe I know why <strong>bash<\/strong> handles the dollar sign input differently from Windows.  I&#8217;ll be sharing my suppositions about that in a coming post.<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continued coverage of the Java Scanner example, this time run on Linux. To find the start of this thread, along with the source code of my Java Scanner example, see my post here. I discuss a test run on Windows &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/the-java-scanner-example-the-linux-test-run\/\"> <span class=\"screen-reader-text\">The Java Scanner example:  the Linux test run<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[605,602,607,614,612,613,611,615],"class_list":["post-9117","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-java-command-line-arguments","tag-java-programming","tag-java-scanner","tag-java-scanner-command-line-arguments","tag-java-scanner-example-on-linux","tag-java-scanner-example-ubuntu-bash","tag-java-scanner-testing","tag-escape"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/9117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=9117"}],"version-history":[{"count":20,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/9117\/revisions"}],"predecessor-version":[{"id":9137,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/9117\/revisions\/9137"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=9117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=9117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=9117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}