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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:16:29+00:00 2026-05-24T10:16:29+00:00

I have an app in which I parse a .txt file from a URL

  • 0

I have an app in which I parse a .txt file from a URL and spit out the string to the user. I want to remove the first 16 characters of the string. How can I do this?

EDIT- I want to remove 16 characters from the data I receive from my http call.

public void onClick(View src) {
        switch(src.getId()) {
        case R.id.buttonRetrieveMetar:


            InputMethodManager imm = (InputMethodManager)   
getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(EditTextAirportCode.getWindowToken(), 0);


            textDisplayMetar.setText ("");


            airportcode = EditTextAirportCode.getText().toString();
            url = urlmetar + airportcode + ".TXT";

            //Added 06-27-11 METAR code
            textDisplayMetar.setText ("");

            try {
                HttpGet httpGet = new HttpGet(url);
                HttpClient httpclient = new DefaultHttpClient();
                // Execute HTTP Get Request
                HttpResponse response = httpclient.execute(httpGet);
                content = response.getEntity().getContent();
                BufferedReader r = new BufferedReader(new     
InputStreamReader(content));
                StringBuilder total = new StringBuilder();
                String line;

                while ((line = r.readLine()) != null) {
                    total.append(line);
                } 
                textDisplayMetar.append("\n" + total + "\n");
                    } catch (Exception e) {
                //handle the exception !
            }


   break;

Thanks!

  • 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-24T10:16:30+00:00Added an answer on May 24, 2026 at 10:16 am

    You can’t modify the string itself, but you can create a substring easily enough:

    line = line.substring(16);
    

    The single-parameter overload of substring takes the whole of the rest of the string after the given start index. The two-parameter overload starts at an index specified by the first argument, and ends at an index specified by the second argument (exclusive). So to get the first three characters after “skipping” the first 16, you’d use:

    line = line.substring(16, 19);
    

    Note that you don’t have to assign back to the same variable – but you need to understand that it doesn’t affect the string object that you call it on. So:

    String original = "hello world";
    String secondPart = original.substring(6);
    
    System.out.println(original); // Still prints hello world
    System.out.println(secondPart); // Prints world
    

    EDIT: If you want to remove the first 16 characters of the whole file, you want:

    textDisplayMetar.append("\n" + total.toString().substring(16) + "\n");
    

    If you want that on a per-line basis, you want:

    while ((line = r.readLine()) != null) {
        total.append(line.substring(16));
    }
    

    Note that both of these may require extra validation – if you call substring(16) on a string with less than 16 characters, it will throw an exception.

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

Sidebar

Related Questions

I have an app which could benefit from the user being able to choose
I have an android app in which i want to convert my string into
I've got an interesting problem. I have an iPad App which has to parse
I want to make an app which (amongst other things) can parse feeds loaded
I am working on app in which I have to parse below JSON. Anyone
Actually i have created an app from which i can stored notes to my
I have an app which uses a UISearchBar to dynamically search from an external
I don't get it. I have two activities in which i parse an XML-file
I have a Ruby on Rails app which handles contacts. Now I want to
I have a very simple Sinatra app which only does log out the params

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.