Could someone try my codes out? It was working a few days ago and now it's not. I did not modify anything, and so I suspect the webmaster of that side has block me. Could someone check it out for me? This is part of my school project.
public class Cost extends TimerTask{ public void run() { Calendar rightNow = Calendar.getInstance(); Integer hour = rightNow.get(Calendar.HOUR_OF_DAY); if (hour==1) { try { URL tariff = new URL("http://www.emcsg.com/MarketData/PriceInformation?downloadRealtime=true"); ReadableByteChannel tar = Channels.newChannel(tariff.openStream()); FileOutputStream fos = new FileOutputStream("test.csv"); fos.getChannel().transferFrom(tar, 0, 1<<24); } catch (IOException ex) { Logger.getLogger(Cost.class.getName()).log(Level.SEVERE, null, ex); } } else { } } }
fos.getChannel().transferFrom(tar, 0, 1<<24);(I guess the FileNotFoundException is thrown here) you could already open a stream so the problem seems to be elsewhere. Please fix all exceptions, even if you think they're not related. If they really aren't they might still hide the actual problem.