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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:50:11+00:00 2026-05-31T07:50:11+00:00

I am currently retrieving some information from a text file (.txt) that contains some

  • 0

I am currently retrieving some information from a text file (.txt) that contains some paragraphs. When I retrieve the String from the text file I want to split it so that I each paragraph is in a String object.

Here is the text I get from the text file:
http://www.carlowweather.com/plaintext.txt

I have tried to split the String using line breaks and return carriage feeds but neither appear to work, see my code below:

 int pCount=0;
public void parseData(String data){
    String regex = "(\\n)";
    String split[] = data.split(regex);
    for(int i = 0; i<split.length; i++){ 
        Log.e("e", pCount + " " + split[i]);
        pCount ++;
    }
}

I have also tried “\r” and various combinations I have found via searching the net but none seem to work on Android with this text file, I’m guessing the file doesn’t contain line breaks or carriage returns? But just blank lines?

What is the best way to split the paragraphs into String objects?

  • 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-31T07:50:13+00:00Added an answer on May 31, 2026 at 7:50 am

    The below code will tell you where a new paragraph break exists. It will be up to you to deal with it after that. It simply looks for lines with ” ” only.
    This is a characteristic of the file you have referred to. I have included the process used to read the file in the code sample below, as you did not specify that in your original question. One thought I had was that you were reading the file line by line and then trying to do the regEx on each line. I would assume that the previous suggestions would work if you read all of the text file into the one String.

    Also, you could break the code up below into another function.

            try {
            BufferedReader in = new BufferedReader(new FileReader("plaintext.txt"));
            String inputDataLine;
            while ((inputDataLine = in.readLine()) != null) {
                if (!(inputDataLine.contentEquals(" "))) {
                    System.out.println("What you want to do with a paragraph line");
                } else {
                    System.out.println("What you want to do with a paragraph seperator");
                }
            }
            in.close();
        } catch (IOException e) {
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I'm retrieving some data from a MySQL database table, but the problem is
Currently I'm doing some unit tests which are executed from bash. Unit tests are
I have been having some issues retrieving JSON data from a WCF service application
Currently programing C# methods to retrieve the following address information: Latitude/Longitude based upon postal
a quick, simple question from me about for-loops. Situation I'm currently writing some high-performance
Currently I am using MySQLi to parse a CSV file into a Database, that
I am currently retrieving both a UserTransaction and a DataSource from a Weblogic 10.3
I'm wondering if there is some command that can be used for retrieving all
I've got a table that holds the location and timestamp information from a GPS
Currently, I store some settings in a database table. It contains 2 fields (setting_name,

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.