Last active
          January 16, 2018 07:02 
        
      - 
      
- 
        Save vamsitallapudi/0ede4a0e283c43788faf34cc6c8d3ff3 to your computer and use it in GitHub Desktop. 
    Read a file in Java Using Buffered Reader
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | BufferedReader reader = null; | |
| try { | |
| reader = new BufferedReader( | |
| new InputStreamReader(getAssets().open("news_data_file.json"), "UTF-8")); | |
| // do reading, usually loop until end of file reading | |
| String mLine; | |
| while ((mLine = reader.readLine()) != null) { | |
| //process line | |
| ... | |
| } | |
| } catch (IOException e) { | |
| //log the exception | |
| } finally { | |
| if (reader != null) { | |
| try { | |
| reader.close(); | |
| } catch (IOException e) { | |
| //log the exception | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment