Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.Iterator;
- import java.util.List;
- public class Bla {
- public static void main(String[] args) {
- List<File> fileList = new ArrayList<File>();
- addFiles(fileList, 10, ".txt");
- writeOutFileList(fileList);
- }
- static void addFiles(Collection<File> c, int index, String fileEnding) {
- for(int i = 0; i < index; i++) {
- c.add(new File(String.valueOf(i) + fileEnding));
- }
- }
- static void writeOutFileList(Collection<File> c) {
- try {
- BufferedWriter bw = null;
- for(Iterator<File> it = c.iterator(); it.hasNext();) {
- bw = new BufferedWriter(new FileWriter(it.next()));
- bw.write("");
- it.remove();
- }
- bw.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement