fast-data-transfer / fdt

FDT is an Application for Efficient Data Transfers which is capable of reading and writing at disk speed over wide area networks (with standard TCP). It is written in Java, runs an all major platforms and it is easy to use. FDT is based on an asynchronous, flexible multithreaded system and is using the capabilities of the Java NIO libraries.
https://fast-data-transfer.github.io/
Apache License 2.0
200 stars 45 forks source link

How to use FDT without CLI #32

Open lucashmsilva opened 6 years ago

lucashmsilva commented 6 years ago

Hi, is there any way I can use the FDT classes through a Java program without having to use a command line interface to invoke the JAR file?

I tried this:

public class Main {

    public static void main(String [] args) {
        String [] arg = {"-c 192.168.0.4 -d C:\\Users\\Remote\\Documents\\ /home/local/bigFile.txt"};
        try {
            FDT.main(arg);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

But, no matter which command arg I pass, the default server is started:

2018-09-02 21:05:25 INFO lia.util.net.copy.FDT main

FDT [ 0.26.1-201708081830 ] STARTED ...


2018-09-02 21:05:25 INFO lia.util.net.common.Config <init> Using lia.util.net.copy.PosixFSFileChannelProviderFactory as FileChannelProviderFactory
2018-09-02 21:05:25 INFO lia.util.net.common.Config <init> FDT started in server mode
2018-09-02 21:05:25 INFO lia.util.net.copy.FDT main FDT uses *blocking* I/O mode.
READY
2018-09-02 21:05:25 INFO lia.util.net.copy.FDTServer doWork FDTServer start listening on port: 54321
erbalazs commented 4 years ago

Hi!

It works for me just fine. Your example is not a proper String array. Use it like this:

String[] fdtParams = { "-c", "localhost", "-pull", "-md5", "-p", "9999" ... }; 

try {
    FDT.main(fdtParams);
} catch (Exception e) {
    e.printStackTrace();
}