如何将 url 转换为带有身份验证的路径?
示例代码:
String url = "https://www.google.com,";
String userpwd = "userName : password";
Path p = Path.get(url.toString());
Files.lines(p);
我实现了通过Buffer reader读取url内容,但我也想使用上面的代码做同样的事情。
最佳答案
试试这个:
String url = "https://www.google.com";
String userpwd = "userName : password";
Path p = Path.of(URI.create(url));
关于Java - 如何将 Files.lines() 的 URL 转换为 PATH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59827771/