+ File file = new File(path);
+ if (file.exists()) {
+ if (file.isDirectory()) {
+ for (File subfile : file.listFiles()) {
+ if (!subfile.isDirectory())
+ files.add(subfile.getAbsolutePath());
+ }
+ } else {
+ files.add(file.getAbsolutePath());
+ }
+ } else {
+ System.err.println("File or directory not found: \"" + path
+ + "\"");
+ }
+ }
+
+ return files;
+ }
+
+ /**
+ * List all the available {@link Card}s on the given network location (which
+ * is expected to be a jVCard remote server, obviously).
+ *
+ * @param path
+ * the jVCard remote server path (e.g.:
+ * <tt>jvcard://localhost:4444/</tt>)
+ *
+ * @return the list of {@link Card}s
+ */
+ static private List<String> list(String path) {
+ List<String> files = new LinkedList<String>();
+
+ try {
+ String host = path.split("\\:")[1].substring(2);
+ int port = Integer.parseInt(path.split("\\:")[2].replaceAll("/$",
+ ""));
+ SimpleSocket s = new SimpleSocket(new Socket(host, port),
+ "sync client");
+ s.open(true);
+
+ s.sendCommand(Verb.LIST);
+ for (String p : s.receiveBlock()) {
+ files.add(path
+ + p.substring(StringUtils.fromTime(0).length() + 1));
+ }
+ s.close();
+ } catch (Exception e) {
+ e.printStackTrace();