Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FilenameFilter;
- import java.util.Scanner;
- public class Potoki implements Runnable {
- public static void main(String[] args) {
- File[] fileList;
- File F = new File("D:\\level2\\");
- FilenameFilter only = new OnlyExt("txt");
- fileList = F.listFiles();
- for (int i = 0; i < fileList.length; i++) {
- if (fileList[i] == only) {
- openFile(fileList[i]);
- readFile();
- closeFile();
- }
- }
- }
- static Scanner x;
- public static void openFile(File file) {
- try {
- x = new Scanner(new File(String.valueOf(file)));
- } catch (Exception e) {
- System.out.println("File not found");
- }
- }
- public static void readFile() {
- while (x.hasNext()) {
- String a = x.next(); //mail
- String b = x.next(); //name
- String c = x.next(); //date
- System.out.printf("%s %s %s\n", a, b, c);
- }
- }
- public static void closeFile() {
- x.close();
- }
- public void run() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment