@Test public void testOpenInputStream() throws Exception { Path file = Paths.get("/tmp/abc.txt"); Files.copy(FileClient.openInputStream("localhost", 19888, "a/simulate.yaml"), file); }
public static InputStream openInputStream(String host, int port, String fileName) throws IOException { Socket socket = new Socket(host, port); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); out.writeUTF("read"); out.writeUTF(fileName); DataInputStream in = new DataInputStream(socket.getInputStream()); if (in.readLong() < 0) { throw new FileNotFoundException(fileName); } return in; }
FileClient { public static InputStream openInputStream(String host, int port, String fileName) throws IOException { Socket socket = new Socket(host, port); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); out.writeUTF("read"); out.writeUTF(fileName); DataInputStream in = new DataInputStream(socket.getInputStream()); if (in.readLong() < 0) { throw new FileNotFoundException(fileName); } return in; } }
FileClient { public static InputStream openInputStream(String host, int port, String fileName) throws IOException { Socket socket = new Socket(host, port); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); out.writeUTF("read"); out.writeUTF(fileName); DataInputStream in = new DataInputStream(socket.getInputStream()); if (in.readLong() < 0) { throw new FileNotFoundException(fileName); } return in; }  }
FileClient { public static InputStream openInputStream(String host, int port, String fileName) throws IOException { Socket socket = new Socket(host, port); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); out.writeUTF("read"); out.writeUTF(fileName); DataInputStream in = new DataInputStream(socket.getInputStream()); if (in.readLong() < 0) { throw new FileNotFoundException(fileName); } return in; }  static void main(String[] args); static InputStream openInputStream(String host, int port, String fileName); }
FileClient { public static InputStream openInputStream(String host, int port, String fileName) throws IOException { Socket socket = new Socket(host, port); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); out.writeUTF("read"); out.writeUTF(fileName); DataInputStream in = new DataInputStream(socket.getInputStream()); if (in.readLong() < 0) { throw new FileNotFoundException(fileName); } return in; }  static void main(String[] args); static InputStream openInputStream(String host, int port, String fileName);  }