Results 1 to 3 of 3
  1. #1
    Adamgal is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Using the Java.io to read an object from the command line

    Hey guys.

    In order to practice Java programming (I've just recently started), I created a "Matrix" class. For those who do not know, a matrix is at its basic just a double array.

    My problem is in trying to get my main method to read a double array from the command line. For instance, I want the user to write "{{1,2},{1,4}}", and have the application
    create a 2X2 array with those numbers.

    I tried using Objectinputstream reader = new objectinputstream(System.in), but at run time this line throws an exception and the method goes immediately to the try block.

    What IO method/methods should I be using if I want to read a double array a user wrote on the command line?

    Thanks!!!

    Adam

  2. #2
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default Re: Using the Java.io to read an object from the command line


  3. #3
    Adamgal is offline Member
    Join Date
    Sep 2011
    Posts
    2
    Rep Power
    0

    Default Re: Using the Java.io to read an object from the command line

    This scanner class doesn't have any method for reading objects like a double array. Is there a similar class that handles that?

Similar Threads

  1. Replies: 16
    Last Post: 09-17-2011, 03:41 AM
  2. Read from command line
    By sehudson in forum New To Java
    Replies: 12
    Last Post: 02-23-2011, 05:44 AM
  3. Replies: 2
    Last Post: 07-02-2010, 03:20 PM
  4. Java command line
    By agouzoul in forum New To Java
    Replies: 2
    Last Post: 04-02-2008, 01:12 PM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 01:23 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
  •