Results 1 to 3 of 3
  1. #1
    tanevn is offline Member
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Default Nooby question :)

    Hello,
    First I'm sorry for the question, but these are my first steps in java :)

    I have main class named "Application" and class "OutputToFile" which make a simple empty text file. How to call OutputToFile in the main class Application??

    Thank you!

    import java.io.File;
    import java.io.IOException;

    public class OutputToFile {

    public static void main(String[] args) {

    try {
    File file = new File("C:\\Java java java\\myfile.txt");
    if (file.createNewFile())
    System.out.println("Success!");
    else
    System.out.println("Error, file already exists.");
    } catch (IOException ioe) {
    ioe.printStackTrace();
    }

    }

    }


    public class Application {

    public static void main(String[] args) {

    }

    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,036
    Rep Power
    20

    Default Re: Nooby question :)

    There's only the one method, so call that.
    Java Code:
    OutputToFile.main(args);
    But you really should give the method a better name, that says what it does.
    It also doesn't seem to need the parameters.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,298
    Rep Power
    20

    Default Re: Nooby question :)

    tanevn, please go through the Forum Rules -- particularly the third paragraph.

    Also go through the Guide For New Members and BB Code List - Java Programming Forum and edit your post accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 2
    Last Post: 05-25-2012, 04:00 PM
  2. question posted by indissa: library question.
    By Fubarable in forum New To Java
    Replies: 2
    Last Post: 11-18-2011, 01:14 AM
  3. Real nooby question but oh well =P
    By Arthur123 in forum New To Java
    Replies: 6
    Last Post: 01-04-2011, 11:57 PM
  4. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM
  5. Extreme nooby having hard time with this app
    By asterix350z in forum New To Java
    Replies: 2
    Last Post: 12-05-2007, 07:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •