Copy folder and its files to another location
<p>I want to copy F:\test to folder F:\123 so that I have folder F:\123\test.</p>

<p>In test folder I hava 2 files: input and output.java
But I can not do that erro is: <strong>F\123\test\output.java (The system cannot find the path specified)</strong></p>

<p>Here is my code:</p>

<pre><code>    Constant.fromPath = "F:\\test"
    Constant.toPath = "F\\123\\test";
    File source = new File(Constant.fromPath);
    File destination = new File(Constant.toPath);

    try
    {
        copyFolder(source, destination);

    }
    catch(Exception ex)
    {
        System.out.println(ex.getMessage());
    }
</code></pre>

<p>Here is copyFolder function</p>

<pre><code> public static void copyFolder(File srcFolder, File destFolder) throws IOException
{
    if (srcFolder.isDirectory())
    {
        if (! destFolder.exists())
        {
            destFolder.mkdir();
        }

        String[] oChildren = srcFolder.list();
        for (int i=0; i &lt; oChildren.length; i++)
        {
            copyFolder(new File(srcFolder, oChildren[i]), new File(destFolder, oChildren[i]));
        }
    }
    else
    {
        if(destFolder.isDirectory())
        {
            copyFile(srcFolder, new File(destFolder, srcFolder.getName()));
        }
        else
        {
            copyFile(srcFolder, destFolder);
        }
    }
}

public static void copyFile(File srcFile, File destFile) throws IOException
{
        InputStream oInStream = new FileInputStream(srcFile);
        OutputStream oOutStream = new FileOutputStream(destFile);

        // Transfer bytes from in to out
        byte[] oBytes = new byte[1024];
        int nLength;
        BufferedInputStream oBuffInputStream = new BufferedInputStream( oInStream );
        while ((nLength = oBuffInputStream.read(oBytes)) &gt; 0)
        {
            oOutStream.write(oBytes, 0, nLength);
        }
        oInStream.close();
        oOutStream.close();
}
</code></pre>

<p>Pls help me to fix my bug.</p>
