SwingWorker Bug

While I was working on a project using Java’s SwingWorker in BomberHughes’ MailWorker class to execute a long task that wouldn’t be practical to freeze the user interface, I stumbled upon a bug that caused me a headache till I could find the problem.

Apparently I trusted blindly the function:

aSwingWorker.cancel(true);

I had in mind that it would just stop the thread’s doInBackground() function right away and would transfer the programme’s flow to done() function. But I trusted wrong. Continue reading SwingWorker Bug

Java Input-Output Streams and UTF-8

Many times, as I (still) live in Greece and have to deal with Greek language and greek charsets, I had frustration over the encoding for various purposes.

The case is solved by using utf-8 in most cases if not all, however, sometimes it is a headache till you configure applications to use utf-8 because most of the times the default is latin1 etc charsets.

Today as I had to deal with this problem again in reading a file in Java, I thought that it would be nice to make a blog post about it, at first as a reminder for me, and also for other people having to deal with similar problems. Continue reading Java Input-Output Streams and UTF-8