Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. zad1.
  2. public class FileScanner {
  3.  
  4. private String fileToScan;
  5. //TODO: Initialize the start value of the counter
  6. private static Long counter;
  7.  
  8. public FileScanner (String fileToScan) {
  9. this.fileToScan=fileToScan;
  10. //TODO: Increment the counter on every creation of FileScanner object
  11. }
  12.  
  13. public static void printInfo(File file) {
  14.  
  15. /*
  16. * TODO: Print the info for the @argument File file, according to the requirement of the task
  17. * */
  18.  
  19. }
  20.  
  21. public static Long getCounter () {
  22. return counter;
  23. }
  24.  
  25.  
  26. public void run() {
  27.  
  28. //TODO Create object File with the absolute path fileToScan.
  29. File file;
  30.  
  31. //TODO Create a list of all the files that are in the directory file.
  32. File [] files = null;
  33.  
  34.  
  35. for (File f : files) {
  36.  
  37. /*
  38. * TODO If the File f is not a directory, print its info using the function printInfo(f)
  39. * */
  40.  
  41. /*
  42. * TODO If the File f is a directory, create a thread from type FileScanner and start it.
  43. * */
  44.  
  45. //TODO: wait for all the FileScanner-s to finish
  46. }
  47.  
  48. }
  49.  
  50. public static void main (String [] args) {
  51. String FILE_TO_SCAN = "C:\\Users\\189075\\Desktop\\lab";
  52.  
  53. //TODO Construct a FileScanner object with the fileToScan = FILE_TO_SCAN
  54. FileScanner fileScanner;
  55.  
  56. //TODO Start the thread from type FileScanner
  57.  
  58. //TODO wait for the fileScanner to finish
  59.  
  60. //TODO print a message that displays the number of thread that were created
  61.  
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement