Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package algorytmy;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- /**
- *
- * @author Długi
- */
- public class Algorytmy {
- void czytaj(){
- FileReader fr = null;
- String line = "";
- try{
- fr = new FileReader("123.txt");
- }catch (FileNotFoundException e){
- System.out.println("Error, could not open a file");
- System.exit(1);
- }
- BufferedReader bfr = new BufferedReader(fr);
- // reading lines from file
- try {
- while((line = bfr.readLine()) != null){
- System.out.println(line);
- }
- } catch (IOException e) {
- System.out.println("Error, could not open a file");
- System.exit(2);
- }
- // closing a file
- try {
- fr.close();
- } catch (IOException e) {
- System.out.println("Error, could not close a file");
- System.exit(3);
- }
- }
- public static void main(String[] args) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement