Question copying files using filechannel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chanshaw
    New Member
    • Nov 2008
    • 67

    Question copying files using filechannel

    Alright I'm trying to copy files from directoryA to directoryB but I can't seem to get this working, any tips!

    Code:
        public void copyFiles()
        {
            try
            {
                System.out.println("Working");
                System.out.println(directoryA);
                FileChannel in = new FileInputStream(directoryA).getChannel();
                FileChannel out = new FileOutputStream(directoryB).getChannel();
                in.transferTo(0, in.size(), out);
            }
            catch(FileNotFoundException ex)
            {
                System.out.println("Filenotfound");
             
            }
            catch(NullPointerException ex)
            {
                System.out.println("NullPointerException");
            }
            catch(IOException ex)
            {
                System.out.println("IOException");
            }
        }
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    What exactly isn't working? And what is the output when you add
    Code:
    ex.printStackTrace();
    in those catch blocks?

    Greetings,
    Nepomuk

    Comment

    Working...