private static void m3() throws IOException {
int[] nums1= {10, 20, 30, 40, 50};
Arrays.stream(nums1).forEach(n->System.out.println(n));
System.out.println();
Data.getStringList().stream().forEach(word->System.out.println(word));
System.out.println();
IntStream.range(1, 11).forEach(n->System.out.println(n));
System.out.println();
try {
Path path=Paths.get(".data.txt");
System.out.println(path.toAbsolutePath());
Files.lines(path).forEach(line->System.out.println(line));
}catch (Exception e) {
}
Path path2=Paths.get(".");
Files.list(path2).forEach(file->System.out.println(file));
System.out.println();
}
private static void m2() {
List<Integer> nums=Data.getIntList(10);
for(int i=0;i<nums.size();i++) {
System.out.printf("%4d", nums.get(i));
}
System.out.println();
for (int i:nums) {
System.out.printf("%4d", i);
}
System.out.println();
Iterator<Integer> iter=nums.iterator();
while(iter.hasNext()) {
System.out.printf("%4d", iter.next());
}
System.out.println();
Stream<Integer> stream=nums.stream();
stream.forEach(new Consumer<Integer>(){
@Override
public void accept(Integer t) {
System.out.printf("%4d", t);
}
});
System.out.println();
nums.stream().forEach(t->System.out.printf("%4d", t));
System.out.println();
Data.getStringList(10).stream().forEach(word->System.out.println(word));
System.out.println();
Data.getUserList().stream().forEach(user->{
System.out.println("[회원정보]");
System.out.println("이름 : "+user.getName());
System.out.println("나이 : "+user.getAge());
System.out.println("성별 : "+(user.getGender()==1?"남자":"여자"));
System.out.println();
});
System.out.println();
Data.getItemList().stream().forEach(item->{
System.out.println(item.getName());
System.out.println(item.getColor());
System.out.println(item.getSize());
System.out.printf("%tF\n", item.getDate());
System.out.println();
});
}