473,385 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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!

Expand|Select|Wrap|Line Numbers
  1.     public void copyFiles()
  2.     {
  3.         try
  4.         {
  5.             System.out.println("Working");
  6.             System.out.println(directoryA);
  7.             FileChannel in = new FileInputStream(directoryA).getChannel();
  8.             FileChannel out = new FileOutputStream(directoryB).getChannel();
  9.             in.transferTo(0, in.size(), out);
  10.         }
  11.         catch(FileNotFoundException ex)
  12.         {
  13.             System.out.println("Filenotfound");
  14.  
  15.         }
  16.         catch(NullPointerException ex)
  17.         {
  18.             System.out.println("NullPointerException");
  19.         }
  20.         catch(IOException ex)
  21.         {
  22.             System.out.println("IOException");
  23.         }
  24.     }
Nov 19 '08 #1
1 1985
Nepomuk
3,112 Expert 2GB
What exactly isn't working? And what is the output when you add
Expand|Select|Wrap|Line Numbers
  1. ex.printStackTrace();
in those catch blocks?

Greetings,
Nepomuk
Nov 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
4
by: Alex Vinokur | last post by:
Copying files : input to output =============================== C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
8
by: needin4mation | last post by:
Please consider: foreach (ListViewItem item in listViewFiles.Items) { // Display the ProgressBar control. pBar1.Visible = true; // Set Minimum to 1 to represent the first file being copied....
10
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in...
2
by: DorkyGrin | last post by:
Can DirectoryWatcher watch subdirectories, copy files that appear, change the name of the files, and send those files to another specified directory? I'm doing this now with a VBS script and using...
15
by: Andrew Meador | last post by:
I am working on an application that will store data in SQL Server 2005 Express. The database will reside on our server at the office. I need to write an application that can work with this data off...
6
by: kimiraikkonen | last post by:
Hi, I use system.io.file class to copy files but i have a difficulty about implementing a basic / XP-like progress bar indicator during copying process. My code is this with no progress bar,...
4
by: Jim Barlow | last post by:
Does anyone know why K&R2 uses the term "File Copying" at this point (1.5.1)? Also, in the K&R2 answers to exercises maintained by Richard Heathfield, for Listing KRX113 Mr Heathfield repeatedly...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.