I need to copy a text file from one server to another (both the servers are Linux). How do I do that in Java?
If you need to copy files from accessible file systems go with Andreas' answer.
If you want a general approach that abstracts from the protocol underneath, have a look at Apache Commons VFS. It provides a common api for resources available through a number of protocols:
Easist if you're able to use apache commons-io: the FileUtils
class has convenient methods to copy files:
FileUtils.copyFileToDirectory(srcFile, targetDirectory);
(as you talked about text files I assume, your application has access to both file systems)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With