I'm trying to copy files from my ipod to a folder on my system.
using this code:
PHP Code:
public class Copy{
public void copyfile(String orig, String dest) throws IOException{
File fOrig = new File(orig);
File fDest = new File(dest);
FileUtils.copyFile(fOrig, fDest);
}
}
when I run the code, only one file is copied with 0 size and gives me an error in the console;
Quote:
C:\Documents and Settings\Administrator\My Documents\aaa
Destination:C:\Documents and Settings\Administrator\My Documents\aaa\Artist - Song.mp3
source:G:\\iPod_Control\\Music\\F00\\ECLH.mp3
java.io.IOException: Error performing inpage operation
at sun.nio.ch.FileDispatcher.pwrite0(Native Method)
at sun.nio.ch.FileDispatcher.pwrite(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.FileChannelImpl.write(Unknown Source)
at sun.nio.ch.FileChannelImpl.transferFromFileChannel(Unknown Source)
at sun.nio.ch.FileChannelImpl.transferFrom(Unknown Source)
at org.apache.commons.io.FileUtils.doCopyFile(FileUtils.java:944)
at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:888)
at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:835)
at Lib.Copy.copyfile(Copy.java:13)
at Lib.Filewalker.walk(Filewalker.java:43)
at Lib.Filewalker.walk(Filewalker.java:19)
at Lib.IpodXtract$3.actionPerformed(IpodXtract.java:277)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I hate this error.
Is this all the code you have? I've seen this error come up when other streams already have the file open. I ask since the FileWalker class looks like it may have something open to the file.
I don't think the Filewalker has it open, howeverthe id3 tag reader might, but I thought that wouldn't be an issue since I'm just coping ?
PHP Code:
public void walk( String path ) throws IOException, TagException {
id3 id3v = new id3(); File root = new File( path ); File[] list = root.listFiles(); int Counter = 0; for ( final File f : list ) { if ( f.isDirectory() ) { walk( f.getAbsolutePath() ); } else {
No, that's why this is such an annoying error (kinda like a 500 in web world at times; it's a little ambiguous as to what it's doing). The problem is if a file is open with a lock, it will often block anything else from opening it at all including the copy.
Pulling tags will guarantee that it has opened the file. But I don't know if it has closed it, and without an actual file object to work with it will be difficult to tell for sure what it has done.
First thing to try, write an overload for the copyfile method that takes two File objects and goes from there. Provide it with f as the source, and create a new file for the destination. See if that works. If not, we'll jump to channel.
i'm not sure what you mean by writing an overload?
also in the filewalker code, is there some way to close the id3 class before the filecopy gets executed?
No, because it doesn't return a ID3v1 object. You can check with that fnt object within that method to see if it has a close mechanism for it.
For an overload, signature with this: public void copyfile(File src, File dest);