Set<String> urlSet=new HashSet<>(List.of(urls));
时间: 2024-05-27 08:11:14 浏览: 16
This line of code creates a new HashSet called urlSet and initializes it with the contents of the List "urls". The "List.of()" method is used to create an immutable List of strings from the input array "urls". The HashSet constructor takes this List as an argument and creates a new HashSet with the same elements as the List. Finally, the "Set<String>" type is used to specify that the HashSet should only contain elements of type "String".
相关问题
sed -i '1 i\<urlset>' $filename
这是一条使用 sed 命令的语句,它的作用是在指定的文件中的第一行之前插入 `<urlset>` 标签。具体来说,`-i` 参数表示直接修改原文件,`1` 表示匹配第一行,`i` 表示在匹配行之前插入文本。需要注意的是,`<` 和 `>` 在 Bash 中是特殊字符,表示重定向符号,因此需要用单引号将整个 sed 命令括起来,以防止 Bash 对这些字符进行解释。
sed -i '1 i<urlset>' $filename为啥能匹配最后一行
这是因为 sed 命令在执行时是按行读取文件的。在执行 `sed -i '1 i<urlset>' $filename` 命令时,sed 会在文件的第一行前插入 `<urlset>`,如果这个文件本身只有一行,则插入的内容会位于这一行的前面。
如果要在文件的最后一行插入 `<urlset>`,可以使用如下命令:
```
sed -i '$ a<\/urlset>' $filename
```
其中 `$` 表示最后一行,a 表示追加命令,`<\/urlset>` 表示要插入的内容。