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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:55:28+00:00 2026-05-28T01:55:28+00:00

I need to load from text file text which I will be replacing in

  • 0

I need to load from text file text which I will be replacing in other string.
For example I have text file:

\n;(br)

After loading this file I need to change all break lines to (br) so I will receive one line string.
Problems is when I’m loading text from file – I don’t get string \n;(br) but \\n;(br)

Anyone know how to do that?

My code – I know that I’m adding ‘\n’ in method applyFilters but it is because that there can be situation when I don’t whant to change that.

    void loadSource(){

    File file = new File(sourcePath);
    BufferedReader reader=null;
    String text;
    try{
        reader = new BufferedReader( new FileReader(file));         
    }catch(FileNotFoundException e){            
        e.printStackTrace();
    }   

    try{
        while((text = reader.readLine()) != null){
            sourceText.add(text);               
        }
    }catch(Exception e){
        e.printStackTrace();
    }       

}

void loadFilters(){

    File file = new File(filterPath);
    BufferedReader reader=null;
    String text;

    try{
        reader = new BufferedReader( new FileReader(file));         
    }catch(FileNotFoundException e){
        System.out.println("Błąd, brak pliku źródłowego");
        e.printStackTrace();
    }

    try{
        while((text = reader.readLine()) != null){
            filterText.add(text);               
        }
    }catch(Exception e){
        e.printStackTrace();
    }       

}

void applyFilters(){

    for (String s : sourceText){
        finalText = finalText+ s + "\n";            
    }
    for(String filter : filterText)
    {           
        finalText = finalText.replace(filter.split(";")[0],filter.split(";")[1]);
    }
    System.out.println(finalText);

}
  • 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-28T01:55:29+00:00Added an answer on May 28, 2026 at 1:55 am

    It sounds like you want the “\n” in your text file to represent a newline character rather than a backslash followed by an n. Have a look at this question:

    How to unescape a Java string literal in Java?

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

Sidebar

Related Questions

Suppose I have a 400K text file which I want to read from a
I have text files which I need to remove stop words from them. I
I have a case where I need to load bitmap from a resource dll
I need to load a file from an umounted TrueCrypt disk into memory. Is
The Junits I have in my project need to load property files from the
I need to load a .xml file from a URL adress into an NSData
I need to create a page that will load divs from an external page
I have an NSImage pointer from a platform SDK, and I need to load
I am completely new to flash. We need to load a binary file from
I have an excel file that i need to open and search it. This

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.