正确截取List指定位置的内容 import java.util.ArrayList; import java.util.List; public class ListUtils { public static <T> List<T> getSubList(List<T> list, int fromIndex, int toIndex) { //list.stream().limit(toIndex); if (toIndex > list.size()) {
写法一: #!/bin/bash while read line do echo $line done < file(待读取的文件) 写法二: #!/bin/bash cat file(待读取的文件) | while read line do echo $line done 写法三: for line in `cat file(待读取的文件)` do echo $line done 说明:for逐行读和while逐行读是有区别的,如: $ cat file aaaa bbbb cccc dddd