Pregunta

I need to copy some files from a PC into a pen drive. I visited JUSB package description, but it is only for windows. So, is there any easy and platform independent way to copy files from computer to USB drive using Java?

¿Fue útil?

Solución

You don't need to worry about the fact that it's a USB drive; when the user inserts the device it is recognized by the OS and shows up as a mounted drive in your filesystem. Then you can just use java.io.File and friends to access it. Additional tip: use org.apache.commons.io.FileUtils as a handy toolkit to make many common file-related tasks easier.

If you need to detect the new USB device automatically in Java, that's a bit tricky. See this question.

Otros consejos

You can take a look at libUsb Java Bindings a javabinding for libUsb. Btw. the jUSB API seems to support Linux too (package: usb.linux), maybe this article can help you: Access USB devices from Java applications

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top