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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:24:17+00:00 2026-06-17T17:24:17+00:00

so lately I’ve been posting similar questions on Java here. Each time someone answers

  • 0

so lately I’ve been posting similar questions on Java here. Each time someone answers my questions, more questions arise.
Thank you all in advance. Solved the append issue, now making things pretty.

[File.java]

public class File {

    public static void main(String[] args) {

        FileWrite fW = new FileWrite();

        try (BufferedReader br = new BufferedReader(new FileReader("B:\\LongIn.dat"))) {
            String stCurrent;
            while ((stCurrent = br.readLine()) != null) {
                System.out.println(stCurrent);
                fW.serializeAddress(stCurrent);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

[FileWrite.java]

public class FileWrite {

    public void serializeAddress(String in) {
        try {
            File file = new File("B:\\LongOut.txt");
            if (!file.exists()) {
                file.createNewFile();
            }

            FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(in);

            bw.close();

            System.out.println("Done");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

Now my program appends when writing strings into the file. But then I have two questions.

  1. On the reading side, what is a good way to deposit a lot of strings into some variable so that my program can play with it?

  2. Append output works, but then it is not nicely organized. As in, the results are meshed up with each other on the output file. How do I make the output all lined up and looking good?

  • 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-06-17T17:24:18+00:00Added an answer on June 17, 2026 at 5:24 pm

    If you want lines to be separated, the easiest thing to do without changing much of your code is to add newLine() call after write() like this:

    bw.write(in);
    bw.newLine();
    bw.close();
    

    Javadoc: BufferedWriter#newLine()

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

Sidebar

Related Questions

Lately I have been trying my hands on Eclipse IDE for java development. I
Lately, I'v been struggling with an annoying situation on ASP.NET MVC. Here's the story
Lately I have been experiencing Eclipse Galileo (3.5) slowing down under Java 1.5b12 OR
Lately I've been playing around with AngularJS and Java EE 6. I've build an
Lately I've been considering creating a sort of toolbox for myself in java. It
Lately I have been playing around with Java's ScriptEngine API, namely the javascript engine,
Lately I have been having more and more issues with the content assist in
Lately, I've been running into more and more poorly designed websites that do things
Lately I've been favoring using named pipes (option --enable-named-pipes) in MySQL running on windows,
Lately I've been thinking a lot about building a website/blog/community oriented site. However I

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.