Witam.
Usiłuję w javie otworzyć plik do odczytu i... po prostu go odczytać ale jakimś cudem ciągle wyskakuje mi błąd kompilacji z nieobsługiwanym wyjątkiem. Nie mam już pojęcia co zrobić, żadna porada znaleziona w internecie nie działa...
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileNotFoundException;
class jtailApp {
public static void main(String[] args) throws FileNotFoundException
{
System.out.println(System.getProperty("user.dir"));
System.out.println(jtailApp.file_get_contents("/etc/hosts"));
}
public static String file_get_contents(String fileName)
{
System.out.println("file_get_contents:");
System.out.println(fileName);
FileReader input = new FileReader(fileName);
StringBuilder contents = new StringBuilder();
char[] buffer = new char[4096];
int read = 0;
while (true)
{
read = input.read(buffer);
contents.append(buffer, 0, read);
}
return contents.toString();
}
}
Środowisko: najnowszy Eclipse z OpenJDK6 na Gentoo Linux
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type FileNotFoundExceptionat jtailApp.main(jtailApp.java:11)
Proszę o pomoc, muszę to błyskawicznie ogarnąć niestety.