while writing a string in a text file using BufferedWriter, how to write in form of a paragraph in java

i am trying to write and store a string  in text file using buffered writer in java .i know how to write in a text file using buffered writer but  when i use it to write in the text file it writes in a single line.i want to write it in the text file  in different line in form of a paragraph.how to do that? please help
sangrag kanjilalAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can use “\r” and “\n” to achieve carriage return and line feed, and then possibly arrange for some padding using “ “ to indent the beginning of the paragraph.
Please show us your code.  
What is the source of your text? Are you writing it at the command line?  Is it being copied from another file?  
Are you using Java 8 or 9? If yes, then why aren't you using  Files.newBufferedWriter  or Files.write ?
awking00Information Technology SpecialistCommented:
How is the string that you want to store generated?
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

sangrag kanjilalAuthor Commented:
from a webpage using jsoup api
I haven't used jsoup. So, I can't help you.  
You should put jsoup in your question title. That way you will attract experts that use jsoup.  
jsoup preserve line breaks  
shows many ideas.
awking00Information Technology SpecialistCommented:
So you're not really "writing" a string, but reading a string from an html document? If so, what is actually being read from the document (e.g. all elements, certain elements, etc.)? Once you can determine which element(s) you need, it should be a rather simple exercise to generate a string value to be parsed or manipulated in the desired manner before writing it to the text file, although formatting as a paragraph can get a little complex. Something like the following might work -
String Filename =  "C:\\mydocs\mytextfile.txt";
FileWriter fw = new FileWriter(Filename);
BufferedWriter bw = new BufferedWriter(fw);
org.jsoup.nodes.Document doc = Jsoup.parse(htmlFile,"UTF-8");
Elements elements = doc.getElementsContainingText("The words or lines I want"); ==> example of getting certain elements
for (Element element: elements) {
  String txt = element.text();
  StringBuilder sb = new StringBuilder(txt); ==> should be helpful in manipulating string to paragraph format
  >>Do StringBuilder manipulations here<<
  String content = sb.toString();

If that looks like it could work for you, I'll try and come up with the paragraph formatting issue. Good luck.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awking00Information Technology SpecialistCommented:
Could you post what you have so far? Perhaps you could also provide a link to an example webpage and what you would expect your test file to look like from that example.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.