All pastes #372930 Raw Edit

Mine

public java v1 · immutable
#372930 ·published 2007-02-26 11:41 UTC
rendered paste body
    /**     * Leser innhold fra fil.     *     * @param filNavn Filen du vil lese fra.     * @return Innholdet fra oppgitt fil.     */    protected String lesFil(File filNavn) {        StringBuffer innhold = new StringBuffer();        BufferedReader input = null;        try {            input = new BufferedReader(new FileReader(filNavn));            String line = null;            while ((line = input.readLine()) != null) {                innhold.append(line);                innhold.append(System.getProperty("line.separator"));            }        } catch (FileNotFoundException e) {            skrivTekst("Filen du oppga eksisterer ikke! Prøv på nytt.");        } catch (IOException e) {            skrivTekst("Noe gikk galt. Sjekk filen og prøv på nytt.");        } finally {            try {                if (input != null) {                    input.close();                }            } catch (IOException e) {                skrivTekst("Noe gikk galt. Sjekk filen og prøv på nytt.");            }        }        return innhold.toString();    }