728x90
반응형
728x170
import 'dart:async';
import 'dart:io';
void main() async {
createDescriptions(['apple', 'orange', 'banana']);
}
Future<void> createDescriptions(Iterable<String> itemIterable) async {
for (String item in itemIterable) {
try {
File file = File('$item.txt');
if (await file.exists()) {
DateTime dateTimeLastModified = await file.lastModified();
print('$item을 위한 파일이 이미 존재합니다. $dateTimeLastModified에 수정되었습니다.');
continue;
}
await file.create();
await file.writeAsString('Start describing $item in this file.');
} on IOException catch (exception) {
print('$item 설명을 생성할 수 없습니다 : $exception');
}
}
}
728x90
반응형
그리드형(광고전용)
'Dart' 카테고리의 다른 글
[DART] Stream<T> 클래스 : async*/yield 키워드 사용하기 (0) | 2021.05.18 |
---|---|
[DART] try ... on ... catch문 사용하기 (0) | 2021.05.18 |
[DART] Future 클래스 : then 메소드 사용하기 (0) | 2021.05.18 |
[DART] Future 클래스 : delayed 팩토리 생성자 사용하기 (0) | 2021.05.18 |
[DART] Duration 클래스 사용하기 (0) | 2021.05.18 |
[DART] import 키워드 : 외부 패키지 임포트하기 (0) | 2021.05.18 |
[DART] String 클래스 : contains 메소드 사용하기 (0) | 2021.05.18 |
[DART] 피보나치 수열 구하기 (0) | 2021.05.18 |
[DART] while문 사용하기 (0) | 2021.05.18 |
[DART] HashSet 클래스 사용하기 (0) | 2021.05.14 |
댓글을 달아 주세요