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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:12:03+00:00 2026-05-24T09:12:03+00:00

so with this piece of code I’ve written, I was wondering why I am

  • 0

so with this piece of code I’ve written, I was wondering why I am not receiving the type of output I want…

//Method to copy over a file to a new file using a delimiter and breaking up the file if it is more than 15 images
    public static void copyFile(File extractedInfo) 
    {
        try
        {
            //Counter to track the # of images/lines
            int c = 0;

            File inputFile = extractedInfo;
            File outputFile = new File(extractedInfo.getParentFile() + "/Extracted Info " + index2++ + ".txt");

            Scanner reader = new Scanner(inputFile);
            reader.useDelimiter("null(U) ");
            BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile));

            //While there is a next line...
            while (reader.hasNextLine())
            {
                //If the document has 15 images, create a new file to write to
                if (c%15 == 0)
                {
                    writer.close();
                outputFile = new File(extractedInfo.getParentFile() + "/Extracted Info " + ((index2++) + 1) + ".txt");
                writer = new BufferedWriter(new FileWriter(outputFile));
                }
                //Else, normally, just write out each individual character from the original file.
                writer.append(reader.next());
                c++;
            }

            reader.close();
            writer.close();
        }
        catch (Exception e)
        {
            e.printStackTrace(System.out);
        }
    }

The original file essentially looks like…

C:\Documents and Settings\workspace\Extracted Items\image2.jpeg;image0;null(U) keyword1, keyword2, keyword3, keyword4,
C:\Documents and Settings\workspace\Extracted Items\image3.jpeg;image1;null(U) keyword1, keyword2, keyword3, keyword4,
C:\Documents and Settings\workspace\Extracted Items\image4.jpeg;image2;null(U) keyword1, keyword2, keyword3, keyword4,
C:\Documents and Settings\workspace\Extracted Items\image5.jpeg;image3;null(U) keyword1, keyword2, keyword3, keyword4,

The problem is, the output file looks exactly the same, but I want everything to be copied EXCEPT the “null(u)” string from the original document. I am just wondering, is my code correct in terms of what I want it to do, and how should I re-work my delimiter to ignore the “null (U)” references in the original file?

Thanks for any offered input.

  • 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-24T09:12:04+00:00Added an answer on May 24, 2026 at 9:12 am

    Changing outputFile within the loop has no effect on writer, you also need to re-create that in the same if (add a second line after the re-assign); and close the old writer before you open the new one.

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

Sidebar

Related Questions

This piece of code reads the size of a file, but the output for
This piece of code used to work in MVC 1 but it does not
Using this piece of code in the head of a page: <script type=text/javascript> function
Given this piece of code : public static void writeFile(File file,List buffer)throws IOException{ File
This piece of code is working fine with normal php: <?php function barber($type) {
Why this piece of code does not work? How to set the length of
This piece of code iterates over a tree of TreeNode objects where every object
This piece of code compiles file in VC6 but in VS 2008 it gives
This piece of code works as I want it to, but in the spirit
This piece of code, file test.py , if 1: print "foo" print "bar" can

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.