how to read text file as variable in java

Solutions on MaxInterview for how to read text file as variable in java by the best coders in the world

showing results for - "how to read text file as variable in java"
Aliya
23 Jan 2018
1public static void readAsString() {
2			 String lCurentDir = System.getProperty("user.dir")+"/aa.txt";
3			 FileReader fr;
4			try {
5				fr = new FileReader(lCurentDir);
6				 BufferedReader br = new BufferedReader(fr);
7		            String s="";
8		            s=br.readLine();
9		            System.out.println(s);
10			} catch (FileNotFoundException e) {
11				// TODO Auto-generated catch block
12				e.printStackTrace();
13			} catch (IOException e) {
14				// TODO Auto-generated catch block
15				e.printStackTrace();
16			}
17	           
18
19		}