Skip to content
Snippets Groups Projects
Commit d162ed18 authored by ik1g19's avatar ik1g19
Browse files

add list operation

parent 036519de
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -31,27 +31,28 @@ public class ClientMain {
try { client.store(new File("test.txt")); } catch(IOException e) { e.printStackTrace(); }
try {Thread.sleep(5000);} catch (InterruptedException e) {System.out.println(e);}
try { client.store(new File("test2.txt")); } catch(IOException e) { e.printStackTrace(); }
try {Thread.sleep(1000);} catch (InterruptedException e) {System.out.println(e);}
// try { client.store(new File("Clipboard01.pdf")); } catch(IOException e) { e.printStackTrace(); }
//
// try { client.store(new File("Clipboard01.jpg")); } catch(IOException e) { e.printStackTrace(); }
//
// String list[] = null;
// try { list = list(client); } catch(IOException e) { e.printStackTrace(); }
String list[] = null;
try { list = list(client); } catch(IOException e) { e.printStackTrace(); }
//
// try { client.load("test.txt", downloadFolder); } catch(IOException e) { e.printStackTrace(); }
// if (list != null)
// for (String filename : list)
// try { client.remove(filename); } catch(IOException e) { e.printStackTrace(); }
try { client.remove("test.txt"); } catch(IOException e) { e.printStackTrace(); }
// try { client.remove("test.txt"); } catch(IOException e) { e.printStackTrace(); }
// try { list(client); } catch(IOException e) { e.printStackTrace(); }
} finally {
if (client != null)
try { client.disconnect(); } catch(Exception e) { e.printStackTrace(); }
if (client != null) try { client.disconnect(); } catch(Exception e) { e.printStackTrace(); }
}
}
......
......@@ -197,6 +197,14 @@ public class Controller extends Server {
file.removeAck();
}
else if (command.equals("LIST")) {
String filenames = fileIndex.entrySet().stream().
map(x -> x.getValue().getFilename()).
collect(Collectors.joining(" "));
send("LIST " + filenames, client, "Client");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment