compile problem
OK, its humbling to have to post someting like this.. but anyway.
I'm writing a simple test program to simply write the date to a new file every however many seconds. But I just can't get it to compile. It tells me that the class MyFileWriter should be declared as abstarct - but I just can't see why. Can anyone set me staright on this one?
Thanks folks.
import java.util.*;
import java.io.*;
import java.nio.*;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
class MyFileWriterextends TimerTask
{
abstractpublicvoid run();
{
System.out.println("File written");
}
}
class MyFileWriterTest
{
publicstaticvoid main(String args[])
{
MyFileWriter fileWriter =new MyFileWriter();
Timer fileTimer =new Timer();
fileTimer.schedule(fileWriter, 2000, 2000);
try
{
for(int n = 10; n > 0; n--)
{
Calendar calendar = Calendar.getInstance();
String time =new String(calendar.get(Calendar.HOUR) +":" + calendar.get(Calendar.MINUTE) +":" + calendar.get(Calendar.SECOND) +":" + calendar.get(Calendar.MILLISECOND));
FileOutputStream fos =new FileOutputStream (new File("Users/damian/Desktop/Test"));
FileChannel channel= fos.getChannel();
ByteBuffer fileText = ByteBuffer.allocate(time.length());
byte[] bytes = time.getBytes();
fileText.put(bytes);
fileText.flip();
channel.write(fileText);
fileText.clear();
fos.close();
}
System.out.println("File written");
Thread.sleep(5000);
}
catch (InterruptedException e)
{
System.out.println("Main thread interrupted");
}
fileTimer.cancel();
}
}

