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

  • SEARCH
  • Home
  • 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 6711179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:06:32+00:00 2026-05-26T08:06:32+00:00

I have made a resource reader with some example code from here . Here

  • 0

I have made a resource reader with some example code from here. Here is my code…

public static void ReadFile() {

    BufferedReader reader = new BufferedReader(new InputStreamReader(file));

    String line;
    try {
        while((line = reader.readLine()) != null){
            String[] values = line.split(",");

            Log.d(TAG, String.valueOf(values.toString()));
        }
    } catch (IOException e) {

        e.printStackTrace();
    }
}

my file is read onResume using this code…

InputStream file = getResources().openRawResource(R.raw.csvfile);

and I think i’ve got it right but when I use the

Log.d()

utility to read the values in my csv file (as shown above) I get something else instead

10-21 20:38:44.096: DEBUG/input(15223): [Ljava.lang.String;@467bbb20
10-21 20:38:44.104: DEBUG/input(15223): [Ljava.lang.String;@467bbfd8
10-21 20:38:44.104: DEBUG/input(15223): [Ljava.lang.String;@467bc3e0
10-21 20:38:44.112: DEBUG/input(15223): [Ljava.lang.String;@467bc7e8
10-21 20:38:44.112: DEBUG/input(15223): [Ljava.lang.String;@467bcbf0
10-21 20:38:44.112: DEBUG/input(15223): [Ljava.lang.String;@467bcff8
10-21 20:38:44.112: DEBUG/input(15223): [Ljava.lang.String;@467bd400
10-21 20:38:44.120: DEBUG/input(15223): [Ljava.lang.String;@467bd808
10-21 20:38:44.120: DEBUG/input(15223): [Ljava.lang.String;@467bdc10
10-21 20:38:44.120: DEBUG/input(15223): [Ljava.lang.String;@467bde60

now I don’t know if you can return straight from a BufferReader like this but there seems to be considerably less values here than there are in my csv file. Here is my csv file

001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000,
001, 000, 000, 000, 000, 000

pretty empty i know but am I getting this right or should my log tags return some readable data, if so what am I doing wrong here.

  • 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-05-26T08:06:33+00:00Added an answer on May 26, 2026 at 8:06 am

    values.toString() is only going to output a representation of the values array (its location in memory, in this case). You need to output the individual values. Something like this:

    for(String s : values) Log.d(TAG, s);
    

    EDIT: You’re also reinitializing values on every run of the while loop. You could either use a StringBuilder, and just keep appending the lines till you reach the end, and then split it into an array, or you could use an ArrayList, store each line in a local String, split it, and append those values to the outer ArrayList.

    No problem. 🙂 Just for future readers, I’ll be glad to add an example anyway.

    With a StringBuilder:

    public static void ReadFile() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(file));
        StringBuilder sb = new StringBuilder();
        String line;
        try {
            while((line = reader.readLine()) != null) { 
                sb.append(line);
            }
            String[] values = (sb.toString()).split(",");
            for(String s : values) Log.d(TAG, s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    

    Or appending per line:

    public static void ReadFile() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(file));
        String line;
        ArrayList<String> values = new ArrayList<String>();
        try {
            while((line = reader.readLine()) != null) { 
                String[] strings = line.split(",");
                for(String s : strings) {
                    values.add(s);
                }
            }
            for(String s : values) Log.d(TAG, s);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    

    These are off my head, so don’t fault me if they don’t compile as-is, haha.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made some code which exports some details of a journal article to
I have made a new windows service which works fine using barebone code (just
I have this code in some of my ASCX files: <%=Html.ActionLink(Resources.Localize.Routes_WidgetsEdit, Edit, Widget, new
I have made a build system for my web application that's rewriting all resource
I have made a class which a form can inherit from and it handles
I have made a user control in asp.net c#. Becuase of some data I
I have some icon resources as DrawingImage s that is made up of many
I made these changes appropriately: Now in 'app/controllers/ users_controller.rb ' I have this code:
I have a static class in which one property defines a resource manager. for
I have a page where the following occurs: some stuff is rendered. static content,

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.