Per quanto riguarda il tuo terzo post il problema è che non hai gestito l'eccezione IO. O fai cosi

codice:
public static void main (String args[]) throws Exception
o fai cosi
codice:
try
{
// tuo codice
} catch (IOException ex) {ex.printStackTrace();}