java - TimerTask not applicable to arguments -


my main program follows:

package pricecollector;  import java.io.bufferedinputstream; import java.io.bytearrayoutputstream; import java.io.fileoutputstream; import java.io.inputstream; import java.net.url; import java.text.dateformat; import java.util.date;  public class app extends timertask {      public static void main(string[] args) {          date = new date();         dateformat df = dateformat.getdateinstance();         string s = df.format(now);          string filename = "/users/desktop/" + s + ".csv";          url link = null;         try {              link = new url("http://finance.yahoo.com/d/quotes.csv?s=iii.l+adm.l+aal.l+anto.l+aht.l+abf.l+azn.l+av.l+bab.l+ba.l+barc.l+bdev.l+blt.l+bp.l+bats.l+blnd.l+bta.l+bnzl.l+brby.l+cpi.l+ccl.l+cna.l+cch.l+cpg.l+crh.l+crda.l+dcc.l+dge.l+dlg.l+dc.l+ezj.l+expn.l+fres.l+gkn.l+gsk.l+glen.l+hmso.l+hl.l+hik.l+hsba.l+imb.l+inf.l+ihg.l+iag.l+itrk.l+intu.l+itv.l+jmat.l+kgf.l+land.l+lgen.l+lloy.l+lse.l+mks.l+mdc.l+merl.l+mcro.l+mndi.l+mrw.l+ng.l+nxt.l+oml.l+ppb.l+pson.l+psn.l+poly.l+pfg.l+pru.l+rrs.l+rb.l+rel.l+rio.l+rr.l+rbs.l+rdsa.l+rdsb.l+rmg.l+rsa.l+sge.l+sbry.l+sdr.l+svt.l+shp.l+sky.l+sn.l+smin.l+sse.l+stj.l+stan.l+sl.l+tw.l+tsco.l+tpk.l+tui.l+ulvr.l+uu.l+vod.l+wtb.l+wos.l+wpg.l+wpp.l&f=np");               inputstream in = new bufferedinputstream(link.openstream());              bytearrayoutputstream out = new bytearrayoutputstream();              byte[] buf = new byte[1024];              int n = 0;              while (-1!=(n=in.read(buf))){                 out.write(buf, 0, n);              }              out.close();              in.close();              byte[] response = out.tobytearray();               fileoutputstream fos = new fileoutputstream(filename);              fos.write(response);              fos.close();         } catch (exception e) {             system.out.println("not available");         }     } } 

this works fine when ran alone, trying set regular schedule make rund daily. timertask program is:

package pricecollector;  import java.util.calendar; import java.util.timer; import java.util.concurrent.timeunit;  public class timertask {      public void runtask(){          calendar calendar = calendar.getinstance();         calendar.set(calendar.hour_of_day, 21);         calendar.set(calendar.minute, 15);         calendar.set(calendar.second, 0);         calendar.set(calendar.millisecond, 0);          timer time = new timer(); // instantiate timer object          // start running task on thursday @ 21:15:00, period set 1 day         // if want run task immediately, set 2nd parameter 0         time.schedule(new app(), calendar.gettime(), timeunit.hours.tomillis(8));       } } 

the final line (schedule argument) give following error:

the method schedule(timertask, date, long) in type timer not applicable arguments (app, date, long)

not sure is. new java! thanks.

the second parameter initial delay shown in api below:

//example, if want configure initial delay 5 seconds time.schedule(new app(), 5000, timeunit.hours.tomillis(8)); 

public void schedule(timertask task, long delay, long period)

task - task scheduled.

delay - delay in milliseconds before task executed.

period - time in milliseconds between successive task executions.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -