package Pliki;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadFile
{
public static void main(String[] args)
{
try(BufferedReader reader = new BufferedReader(new FileReader("/etc/passwd")))
{
while (true)
{
String line = reader.readLine();
if(line == null)
{
break;
}
System.out.println(line);
}
reader.close();
}
catch (FileNotFoundException e)
{
System.err.println("There is no such file");
}
catch (IOException e)
{
System.err.println("IOExceptions");
}
}
}
Brak komentarzy:
Prześlij komentarz