473,503 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question copying files using filechannel

67 New Member
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 1991
Nepomuk
3,112 Recognized Expert Specialist
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
3618
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
2943
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
8207
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
19582
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
7803
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
1245
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
1717
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
4952
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
1594
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...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.