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 2 of 2

Thread: How to schedule this to happen daily?

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to schedule this to happen daily?

    Hello everyone,

    Can any of you help me schedule this to run daily at some hour? Thanks...



    import java.net.*;
    import java.io.*;


    public class URLReader {


    public static String outFile = "C://test//Test.txt";

    public static void main(String[] args) throws Exception {
    URL oracle = new URL("http://www.oracle.com/");
    URLConnection yc = oracle.openConnection();


    BufferedReader in = new BufferedReader(new InputStreamReader(
    yc.getInputStream()));
    String inputLine;

    BufferedWriter psout = new BufferedWriter(new FileWriter(outFile));

    while ((inputLine = in.readLine()) != null) {
    psout.write(inputLine);
    System.out.println(inputLine);
    }
    in.close();
    psout.close();
    }
    }


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,166
    My Mood
    Hungover
    Thanks
    141
    Thanked 597 Times in 512 Posts

    Default Re: How to schedule this to happen daily?

    There are a few ways to do this. Either use a Timer, or implement some kind of polling mechanism. Which one you choose is really up to you.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Timer.schedule
    By johnboyofsj in forum Java Theory & Questions
    Replies: 1
    Last Post: October 14th, 2012, 10:02 PM
  2. [SOLVED] Is there a way to make things happen if a certain text is entered in a TextField?
    By DusteroftheCentury in forum Java Theory & Questions
    Replies: 25
    Last Post: January 26th, 2012, 07:14 PM
  3. Program to calculate pay and total sum with daily increment. Urgent!
    By ePerKar3 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: December 5th, 2011, 12:20 PM
  4. why could this happen?
    By bvk1013 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 17th, 2011, 10:48 PM
  5. How to schedule a Java Program for Background processing
    By rangarajank in forum Java Theory & Questions
    Replies: 5
    Last Post: May 13th, 2010, 03:57 AM