Java I\O

This is a discussion on Java I\O within the C# Programming forums, part of the General Programming Boards category; ok, all this talk about C# is making me hungry for Java. Does any body know how to do a ...

  1. #1
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035

    Java I\O

    ok, all this talk about C# is making me hungry for Java. Does any body know how to do a Hello World progam in Java? It's a console Application. So far I have this:
    Code:
    public class Class1
    {
    
    	public static void main (String[] args)
    	{
    		//Whats the code for output?
    	}
    }
    thanks.

  2. #2
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    .
    Last edited by Troll_King; 11-30-2001 at 11:19 AM.

  3. #3
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    thanks, but what about input?

  4. #4
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    input? anybody?

    Code:
    class Class1
    {
              int input; //for the input
              public static void main(String args[])
              {
                     //System.in.WHAT?
              }
    }
    Last edited by Xterria; 11-10-2001 at 11:53 PM.

  5. #5
    Unregistered
    Guest
    The answer to your question is not simple.

    Unlike C++ where you can go:

    cout << "Hello World" << endl;

    Java I/O is not simple. Why? Many reason.

    I suggest you pick up a college level text and look at examples.

  6. #6
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    with
    cout << "Hello World!" << endl;
    you can go
    System.out.println("Hello World!\n");

    looks simple to me.

  7. #7
    Registered User
    Join Date
    Aug 2001
    Posts
    5
    Haven't done java for a couple years.. but I believe it's
    Code:
    var = System.in.read();
    If I'm wrong.. I wouldn't be surprised, as that's off the top of my head..

  8. #8
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    thanks, but it still isn't working

  9. #9
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Try this -

    Code:
    import java.io.*;
    
    class test {
    	public static void main( String[] args ) {
                 
                
                try{
                    
                    BufferedReader stdin =new BufferedReader(new 
                                              InputStreamReader(System.in));
                     String a = new String();
                     a=stdin.readLine();
                     System.out.print(a);
                }
                catch(IOException e) {
                     System.out.println("IO Exception");
             }
               
                
                
          }
    }
    zen

  10. #10
    Registered User
    Join Date
    Sep 2001
    Posts
    6
    class ReadChar
    {
    public static void main(String[] args)
    throws java.io.IOException
    {
    char c;
    System.out.println("Hit a Key and press enter"):
    c = (char)System.in.read();
    System.out.println("You typed " + c);
    }

    }

  11. #11
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    yes! thank you!!!

  12. #12
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    How here wants a Java board? (I do.) Face it, C# is just as much C as Java is. They both share similar "C" syntax, but aside from that, they aren't C.

    That being the case, a Java board would do nicely.

    Quzah.
    Hope is the first step on the road to disappointment.

  13. #13
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    I'm with you.

  14. #14
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    He he...

    I've had my fingers burned here before for promoting Java......No one took much notice......

    If you want a good resourse try JavaRanch. They have a board bigger than us and you will find whatever you may need there.........

    Just be carefull....they can be touchy about stuff like names.....If you go on as a one word alias they get snooty.......

    Excellent info though....

  15. #15
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    Applet Version. Courtesy of Me.

    If you wanted to do this in an applet, the simplest form, no color, no nada, just text, here is the source code:

    /** - documented comments, if you haven't heard of these, you can just use /* and */
    AppHW.java - Main source code.
    AppHW - Hello World! for a Java applet
    Programmer: Sean Mackrory
    */

    import java.applet.Applet

    class AppHW
    {
    public void init()
    {
    Label HW = new Label("Hello World!");
    add(HW);
    };
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java Binary File IO
    By Wraithan in forum Tech Board
    Replies: 1
    Last Post: 07-01-2006, 05:01 AM
  2. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 03:06 PM
  3. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 10:07 PM
  4. Java File IO
    By Korn1699 in forum Tech Board
    Replies: 3
    Last Post: 03-09-2004, 02:08 PM
  5. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 01:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21