import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; public class Fil { public static void main(String[] args) throws Exception { String line; Scanner sc = null; // Vi maa sette den til noe. try { sc = new Scanner(new File("navn.txt")); } catch (FileNotFoundException e) { System.out.println("error reading file: " + e); } while (sc.hasNextLine()) { line = sc.nextLine(); if (! line.equals("")) { // Sjekker for tomme linjer i filen. System.out.println("Hei " + line + ", Velkommen til IN1010!"); } } } }