Reading different variables from text file in Java code example

Example: how to read text file as variable in java

public static void readAsString() {
			 String lCurentDir = System.getProperty("user.dir")+"/aa.txt";
			 FileReader fr;
			try {
				fr = new FileReader(lCurentDir);
				 BufferedReader br = new BufferedReader(fr);
		            String s="";
		            s=br.readLine();
		            System.out.println(s);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	           

		}

Tags:

Java Example