JAVA : write a method partitionFile?

Programming
Tutor: None Selected Time limit: 1 Day

I have the following java program called MultiBufferedWriter

import java.io.BufferedWriter;
import java.io.FileWriter;import java.util.ArrayList;import java.io.IOException;import java.util.Scanner;

public class MultiBufferedWriter{

  private ArrayList<BufferedWriter> writers;
  private int currentFile;  public MultiBufferedWriter(String filePattern, int n) throws IOException  {

    this.currentFile = 0;
   ArrayList<BufferedWriter> dog = new ArrayList<BufferedWriter>();    writers = dog; for(int i = 0; i < n; i++) {  BufferedWriter out = new BufferedWriter(new FileWriter(filePattern+(i+1)));writers.add(out);  }}

  public void write(String mouse) throws IOException
{
for(int i = 0; i < writers.size(); i++){writers.get(currentFile).write(mouse); 

      currentFile++;

    }

    currentFile = 0;

  }

  public void close() throws IOException

  {

    for(int i = 0; i < writers.size(); i++)

    {

    writers.get(i).close();

    } 

  }

  public void newLine() throws IOException

  {

    for(int i = 0; i < writers.size();i++)

    {

    writers.get(currentFile).newLine();

    }

  }

}

___________________________________________________________________________

How do i write a method partitionFile which takes as input a String souce a String destination and an int n. Using the class MultiBufferedWriter( which i have written out already and it compiles) it should partition the source file into several files with the pattern destination + i for ranges of i to 1 until n.

Nov 30th, -0001
The only reason I can think of is that you have a class called FileWriter in the same package as the class, from which you've copied the code fragments. In that case, you are not allowed to import a FileWriter class from a different package, but have to use the qualified name (java.io.FileWriter) in the code itself.
Jul 2nd, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Nov 30th, -0001
...
Nov 30th, -0001
Mar 23rd, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer