<dependency> <groupId>com.github.jnr</groupId> <artifactId>jnr-unixsocket</artifactId> <version>0.24</version> </dependency> import jnr.unixsocket.UnixSocket; import jnr.unixsocket.UnixSocketAddress; String socketPath = "/path/to/unix/socket/file"; UnixSocketAddress address = new UnixSocketAddress(socketPath); UnixSocket socket = UnixSocket.createUnixSocket(); socket.connect(address); BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } File file = new File("/path/to/file"); if (file.delete()) { System.out.println("File deleted successfully."); } else { System.out.println("Failed to delete the file."); } socket.close();


上一篇:
下一篇:
切换中文