Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package readfile;
- /**
- *
- * @author Riham
- */
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.FileReader;
- import java.util.ArrayList;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class ReadFile1 {
- public static void main(String args[]){
- ArrayList<String> list=new ArrayList<String>();
- BufferedReader br=null;
- try {
- br= new BufferedReader(new FileReader("C:\\Users\\User\\Desktop\\riham.txt"));
- String i=null;
- while((i=br.readLine())!=null){
- list.add(i);
- }
- for(String x:list)System.out.println(x);
- } catch(IOException e){
- e.printStackTrace();
- } finally{
- try {
- br.close();
- } catch (IOException ex) {
- Logger.getLogger(ReadFile1.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement