I want to call rsync from Java using Runtime.exec() and I want to ignore hidden files/folders. The command is simple and works like a charm at the command line.
rsync -r --exclude=".*" source destination
I have tried many, many different combinations of breaking these arguments down correctly to be passed as a String[] to exec(). I have failed and I may be close to losing my mind.
Some examples of what I have tried
String[]{ "rsync", "-r", "--exclude", "=", ".*", source, destination});
String[]{ "rsync", "-r", "--exclude", "=", "\".*\"", source, destination});
String[]{ "rsync", "-r", "--exclude=\".*\"", source, destination});
Most of the time I end up with an exit 23 (which is "partial transfer due to error"), the transfer completes but includes hidden files/folders.