Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Changing output from console to .html

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Changing output from console to .html

    hi ive got a project that i need to output to a .html file and i also need to make sure that i include HTML elements such as <td></td> i'm new to java and need a starting point for this.

    Removed code due to other students googling it and copying my code.
    Last edited by RSYR; December 16th, 2009 at 12:24 PM. Reason: Removed code due to other students googling it and copying my code.


  2. #2
    Junior Member
    Join Date
    Nov 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Changing output from console to .html

    right i've managed to edit the program so it outputs to the console and to a .html file when i run it. but my assignment says i need it only needs to output to html when a command such as:

    java Generator –html results0809.txt

    is run... but i don't really understand this as i just run the program in eclipse?

    thanks

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Changing output from console to .html

    In Eclipse, go to Run->Run Configurations... and click on the arguments tab. From there you can enter command line arguments, such as "–html results0809.txt". These are then passed to your args parameter in the main method, where they should be dealt with accordingly.

  4. #4
    Junior Member
    Join Date
    Nov 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Changing output from console to .html

    thanks for the reply i understand it better now but i still don't see what i'm asking my program to run if you understand what i mean... what is the actual -html supposed to do? is it a class im asking the program to run or what?

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Changing output from console to .html

    Quote Originally Posted by RSYR View Post
    what is the actual -html supposed to do?
    This is up to the program. Placing text after the class name (or jar name) when running from the command line is a way of passing data to your program. Your program can intercept these in the main function. For example:

    java Generator –html results0809.txt

    In the main method what happens is
    public static void main( String args[] ){
        ///args[0] is "-html"
       ///args[1] is "results0809.txt"
    }

    So in your case you can determine whether to output to html, and what file to do so, by checking the args parameter.

  6. #6
    Junior Member
    Join Date
    Nov 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Changing output from console to .html

    thanks for the reply again i'll read up on it

  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Changing output from console to .html

    Quote Originally Posted by copeg View Post
    This is up to the program. Placing text after the class name (or jar name) when running from the command line is a way of passing data to your program. Your program can intercept these in the main function. For example:

    java Generator –html results0809.txt

    In the main method what happens is
    public static void main( String args[] ){
        ///args[0] is "-html"
       ///args[1] is "results0809.txt"
    }

    So in your case you can determine whether to output to html, and what file to do so, by checking the args parameter.
    hi again, i'm not really getting it would you mind if i posted my attempt so you could tell me where i'm going wrong? sorry to be a bother thanks

Similar Threads

  1. Parameter's value is never changing
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 27th, 2009, 05:29 AM
  2. printing output to console & to a text file at the same time...
    By prasanna in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: August 26th, 2009, 03:43 AM
  3. [SOLVED] help with console input strnig....
    By mdstrauss in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: August 17th, 2009, 03:59 AM
  4. Changing colors of large image in real time
    By chals in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: May 7th, 2009, 05:06 AM