Advertisement
Mary_Loskutova

123

Mar 19th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. import java.io.BufferedReader;
  2.  
  3. import java.io.FileNotFoundException;
  4. import java.io.FileReader;
  5. import java.util.ArrayList;
  6. import java.util.Scanner;
  7.  
  8. public class File  {
  9.  
  10.     String fileName;
  11.     ArrayList<String> filelist;
  12.  
  13.     File(String fileName, ArrayList<String> filelist) {
  14.         this.fileName = fileName;
  15.         this.filelist = new ArrayList<String>();
  16.     }
  17.  
  18.     public static ArrayList<String> readFile(String name) throws FileNotFoundException {
  19.         Scanner scanner = null;
  20.         scanner = new Scanner(new BufferedReader(new FileReader(name)));
  21.         ArrayList<String> filelist = new ArrayList<String>();
  22.         while (scanner.hasNextLine()) {
  23.         filelist.add(scanner.nextLine());
  24.        
  25.         } return filelist;
  26.         }
  27.    
  28. }
  29.  
  30.  
  31.  
  32. import java.util.ArrayList;
  33.  
  34. public class Spy extends Thread {
  35.     ArrayList<File> fileCollection;
  36.        
  37.     public Spy () {
  38.     this.fileCollection = new ArrayList<File> ();
  39.         }
  40.    
  41.     public void addFile (File file) throws InterruptedException {
  42.         this.fileCollection.add(file);
  43.        
  44.     }
  45.        
  46.    
  47.    
  48.     public void observeFile () {
  49.         for (File fileobservable : fileCollection) {
  50.             if (fileCollection.get(0).equals(fileCollection.get(1))) {
  51.                     System.out.print("true"+fileobservable);
  52.                 } else {
  53.                     System.out.print("hhh");
  54.                 }
  55. }
  56. }
  57.    
  58.     public void run() {
  59.         this.observeFile();
  60.     }
  61.  
  62.     public void addFile(ArrayList<String> file1) {
  63.         // TODO Auto-generated method stub
  64.        
  65.     }
  66.  
  67.    
  68.  
  69.    
  70.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement