Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:20:56+00:00 2026-06-15T14:20:56+00:00

I am trying to read lines stored in a separate text file into my

  • 0

I am trying to read lines stored in a separate text file into my android application and have each line show up in the list view.

The problem is that I cannot get anything to appear despite the fact my code says their are not errors in it. As you read this code, I will clarify that my ListView is named “addresslist” and the file i’m reading from is named “myaddress.txt”. I appreciate any help.

ListView listView= (ListView) findViewById(R.id.addresslist); 
try{
    InputStream instream = openFileInput("myaddress.txt");

    InputStreamReader inputreader = new InputStreamReader(instream);
    BufferedReader buffreader = new BufferedReader(inputreader);


    ArrayList<String> lines = new ArrayList<String>();
    boolean hasNextLine =true;
    while (hasNextLine){
        String line =  buffreader.readLine();
        lines.add(line);
        hasNextLine = line != null;
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.id.addresslist,lines);

    listView.setAdapter(adapter);

    instream.close();

    }
    catch(java.io.FileNotFoundException e){

    }catch(java.io.IOException e){

    }

}

With the following errors in the log:

12-08 01:21:30.394: E/Trace(1500): [ 12-08 01:21:30.864  1500: 1500 V/Home to School 4828 N. Crescent Norridge IL 60706, 5500 N St Louis Avenue Chicago IL 60625; Home to School 4828 N. Crescent Norridge IL 60706, 5500 N St Louis Avenue Chicago IL 60625; 
12-08 01:21:30.864: D/AndroidRuntime(1500): Shutting down VM
12-08 01:21:30.924: W/dalvikvm(1500): threadid=1: thread exiting with uncaught exception (group=0xb3e92288)
12-08 01:21:30.944: E/AndroidRuntime(1500): FATAL EXCEPTION: main
12-08 01:21:30.944: E/AndroidRuntime(1500): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tripapp/com.tripapp.Frontpage}: java.lang.NullPointerException: println needs a message
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.os.Looper.loop(Looper.java:137)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.ActivityThread.main(ActivityThread.java:4745)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at java.lang.reflect.Method.invokeNative(Native Method)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at java.lang.reflect.Method.invoke(Method.java:511)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at dalvik.system.NativeStart.main(Native Method)
12-08 01:21:30.944: E/AndroidRuntime(1500): Caused by: java.lang.NullPointerException: println needs a message
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.util.Log.println_native(Native Method)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.util.Log.v(Log.java:117)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at com.tripapp.Frontpage.onCreate(Frontpage.java:61)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.Activity.performCreate(Activity.java:5008)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
12-08 01:21:30.944: E/AndroidRuntime(1500):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
12-08 01:21:30.944: E/AndroidRuntime(1500):     ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:20:58+00:00Added an answer on June 15, 2026 at 2:20 pm

    First move your file in assets folder in your project and use this code for reading file from assets folder :

        try{
        InputStream inputreader = getAssets().open("myaddress.txt");
        BufferedReader buffreader = new BufferedReader(new InputStreamReader(inputreader));
    
       // your code here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read the last line from a text file. Each line starts
I have a list of files stored in a text file. I read the
I have a file with multiple strings, each string on a separate line. All
I have been trying to read a txt file. The txt file contains lines
I'm trying to create the program to read each lines and calculate each line's
I am trying to read the number of lines of a file I found
I'm trying to read a file line by line starting from a specific line
I'm trying to read a file line by line to a string type variable
I am trying to read a file line-by-line, and storing that line of data
I am trying to read the number of line in a binary file using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.