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

The Archive Base Latest Questions

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

I got my little html fisher working and it grabs a text file form

  • 0

I got my little html fisher working and it grabs a text file form a URL string. I can call setText to my EditText view and it will indeed display the text in the text file, but there is like no formatting at all (I am talking simple stuff like carriage returns and line feeds). How can I get this to render a bit more nicely in the EditText? Original text file looks like:

Imagine the following from a resource:

http://www.someaddress.com/thetextfile.txt

Original Text File here.  

1. First thing on the text file.

2. Second thing on the text file...

   Finally the end of the text file.  This is a long string blah blah
that I like to use here.  Notice the carriage return line breaks and indentation
on the paragraph.

I can get the above as a string but there is no carriage returns at all when it displays in the EditView. Is there anyway I can add this? Its not a matter of adding \n or \r cause those would already be in the text file I would suspect (was written in Notepad++). So is there anyway to get this even ever so slightly more formatted? (and preserve the formatting when the string is saved back out to disk or to a database?

EDIT:

<EditText android:id="@+id/contract_text_input"
        android:layout_width="650sp" android:layout_height="wrap_content"
        android:lines="25"
        android:scrollbars = "vertical"
         android:gravity="top|left" android:inputType="textMultiLine"
        android:scrollHorizontally="false" 
        android:minWidth="10.0dip"
        android:maxWidth="5.0dip"/>

EDIT:

These are the methods that fetch this text file from the internet. They seem to be ripping out all the \n and \r. But if I inspect that file that’s on line it only has \t’s in it. So maybe its filezilla’s uploading to my webserver of the file?

public static InputStream getInputStreamFromUrl(String url){
            InputStream contentStream = null;

            try{
              HttpClient httpclient = new DefaultHttpClient();
              HttpResponse response = httpclient.execute(new HttpGet(url));
              contentStream = response.getEntity().getContent();
            } catch(Exception e){
               e.printStackTrace();
            }
            return contentStream;
         }

  public static String getStringFromUrl(String url)  {
         BufferedReader br = new BufferedReader(new InputStreamReader(getInputStreamFromUrl(url)));

         StringBuffer sb = new StringBuffer();

         try{
          String line = null;

          while ((line = br.readLine())!=null){
           sb.append(line);
          }
         }catch (IOException e){
          e.printStackTrace();
         }
         return sb.toString();
  }

This is how I am ultimately updating the EditText:

private class FragmentHttpHelper extends AsyncTask<Void, Void, String>{
         protected void onPostExecute(String result) {               


                contractTextTxt.setText(result);
            }
        @Override
        protected String doInBackground(Void... params) {

            return getStringFromUrl(urlReferenceTxt.getText().toString());

        }         
    }
  • 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-24T07:29:02+00:00Added an answer on May 24, 2026 at 7:29 am

    Hi sorry I just did a similar thing in an app of mine

    and called

    ((EditText) findViewById(R.id.textView1))
                .setText("Original Text File here.\r\n\r\n1. First thing on the text file.\r\n\r\n2. Second thing on the text file...\r\n\r\n   Finally the end of the text file.  This is a long string blah blah that I like to use here.  Notice the carriage return line breaks and indentation on the paragraph.");
    

    which would be the same as your string

    and I get

    enter image description here

    which looks fine to me!

    my edit text was

    <EditText   android:id="@+id/textView1" android:layout_width="wrap_content"
        android:layout_weight="0" android:layout_height="wrap_content"></EditText>
    

    edit sorry huge image

    edit2: check the debugger’s string value
    enter image description here

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

Sidebar

Related Questions

I'm working on a little html/css framework that I can use for most of
I've got an html form text field that normally handles key up/down events. However,
I'm working on a little experiment here. I've got a test file that I
I've got a little HTML/CSS/JQuery drop down menu working. My pseudo code for it
Got my little mechanize code: br.open('http://tumblr.com/customize'); print br.response().read() print br.form['edit_tumblelog[cname]'] # there definitely is
I got a little problem. Sometimes, when I try to call the following code,
i got a got a little embedded system that can be controlled via a
I've got a little problem with exporting MySQL data to html. The problem is
I got a little problem and nothing I test seems to work. My HTML:
What is the best way to gray out text inputs on an HTML form?

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.