Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class File {
- ArrayList<String> filelist;
- File(ArrayList<String> filelist) {
- this.filelist = new ArrayList<String>();
- }
- public static File readFile(String name) throws FileNotFoundException {
- Scanner scanner = null;
- scanner = new Scanner(new BufferedReader(new FileReader(name)));
- ArrayList<String> filelist = new ArrayList<String>();
- while (scanner.hasNextLine()) {
- filelist.add(scanner.nextLine());
- }
- File file = new File(filelist);
- return file;
- }
- }
- public class Spy extends Thread {
- ArrayList<File> fileCollection;
- public Spy() {
- this.fileCollection = new ArrayList<File>();
- }
- public void obsFile(File filelist) throws InterruptedException {
- boolean b = true;
- while (b) {
- this.fileCollection.add(filelist);
- Thread.sleep(1500);
- int a = fileCollection.size() - 1;
- System.out.println(fileCollection.get(0).equals((fileCollection.get(a))));
- }
- }
- }
- public class Test {
- public static void main(String[] args) throws InterruptedException {
- System.out.print("Enter the first file name" + "\n");
- Scanner sc = new Scanner(System.in);
- String Name = sc.nextLine();
- try {
- File file1 = File.readFile(Name);
- Spy spy = new Spy();
- spy.obsFile(file1);
- } catch (FileNotFoundException ex) {
- System.out.print("There are no files with such name!");
- sc.close();
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement