Code example for BufferedReader

Methods: close, readLine

0
 
	public static JSONObject readAutocompleteFile(Context c, long accId) {
		try { 
			FileInputStream fis = c.openFileInput("autocomplete-" + accId
					+ ".json"); 
			BufferedReader br = new BufferedReader(new InputStreamReader(fis));
			JSONObject ja = new JSONObject(br.readLine());
			br.close();
			fis.close();
			return ja;
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return null; 
	} 
 
	public static boolean saveAutocompleteFile(Context c, long accId,
			JSONObject ja) {
		try { 
			FileOutputStream fos = c.openFileOutput("autocomplete-" + accId
					+ ".json", Context.MODE_PRIVATE);