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 8404697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:39:54+00:00 2026-06-09T22:39:54+00:00

My Program needs to be able to scan a text file, and store the

  • 0

My Program needs to be able to scan a text file, and store the values of the text file into a database.
Suppose I’ve read in a line of code that looks like this

3,95003,"ALLENDALE",,41.030902,-74.130957,2893

I want to be able to call a part of the string and store it as a database value. How exactly would I do that? I already know how to read in text files, but i need to know how to filter and only grab a part of them.

In a database I would usually add a value by doing something like this.

values.put("A", "B");

How can i read a value from only part of the textfile into B?

Say I want it to display values.put(“A”, “ALLENDALE”).

Answer:

AgencyString = readText();
        tv = (TextView) findViewById(R.id.letter);

        tv.setText(readText());

        StringTokenizer st = new StringTokenizer(AgencyString, ",");
        while (st.hasMoreElements()) {
            tv.setText(st.nextToken());
        }
    }

    private String readText() {
        InputStream inputStream = getResources().openRawResource(R.raw.agency);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        int i;
        try {
            i = inputStream.read();
            while (i != -1) {
                byteArrayOutputStream.write(i);
                i = inputStream.read();
            }
            inputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return byteArrayOutputStream.toString();

    }

The next step for me is to store these values seperated into an array, and read them into my database. I was able to filter through my agency.txt file by using a StringTokenizer method and setting a ‘comma’ as my delimiter.

  • 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-09T22:39:56+00:00Added an answer on June 9, 2026 at 10:39 pm

    Look at. Use delimiters “,”.
    http://developer.android.com/reference/java/util/StringTokenizer.html
    http://developer.android.com/reference/java/lang/String.html#split(java.lang.String)

    http://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html
    http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String, int)

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

Sidebar

Related Questions

I have a program that needs to store data values and periodically get the
I'm writing a program that needs to be able to read in the time
I am writing a program that needs to be able to work with text
I'm writing a C++ program which needs to be able to read a complex
I have a program that I need to be able to search a file
I am writing a program that needs to read a set of records that
I'm working on a program that needs to be able to load object-properties from
Im writing a program that needs to be able to find the difference between
I am writing an MPI program that needs to read a part of a
I'm writing a program that needs to be able to kill certain processes. The

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.