package com.mycompany ;
import java.io.IOException ;
import java.nio.file.* ;
import java.util.Scanner ;
import static java.nio .file .StandardWatchEventKinds .*;
public class App {
WatchService watcher = FileSystems.getDefault ( ) .newWatchService ( ) ;
Path path = FileSystems.getDefault ( ) .getPath ( "/home" , "vpupkin" ) ;
System .
out .
println ( path.
toString ( ) ) ; WatchKey key =
path.register ( watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY) ;
do {
WatchKey watchKey = null ;
try {
watchKey = watcher.take ( ) ;
return ;
}
for ( WatchEvent<?> event : watchKey.pollEvents ( ) ) {
WatchEvent.Kind <?> kind = event.kind ( ) ;
if ( kind == OVERFLOW) {
continue ;
}
WatchEvent< Path> ev = ( WatchEvent< Path> ) event;
Path filename = ev.context ( ) ;
Path child = path.resolve ( filename) ;
try {
contentType = Files.probeContentType ( child) ;
e.printStackTrace ( ) ;
continue ;
}
if ( null == contentType) {
continue ;
}
if ( ! contentType.equals ( "text/plain" ) ) {
System .
err .
format ( "New file '%s'" + " is not a plain text file.%n" , filename) ;
continue ;
}
System .
out .
format ( "Emailing file %s%n" , filename
) ; }
boolean valid = key.reset ( ) ;
if ( ! valid) {
return ;
}
} while ( true ) ;
} ) ;
t.start ( ) ;
Scanner sc
= new Scanner
( System .
in ) ; do {
next = sc.next ( ) ;
} while ( ! next.equals ( "stop" ) ) ;
t.interrupt ( ) ;
}
}
cGFja2FnZSBjb20ubXljb21wYW55OwoKaW1wb3J0IGphdmEuaW8uSU9FeGNlcHRpb247CmltcG9ydCBqYXZhLm5pby5maWxlLio7CmltcG9ydCBqYXZhLnV0aWwuU2Nhbm5lcjsKCmltcG9ydCBzdGF0aWMgamF2YS5uaW8uZmlsZS5TdGFuZGFyZFdhdGNoRXZlbnRLaW5kcy4qOwoKcHVibGljIGNsYXNzIEFwcCB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB0aHJvd3MgSU9FeGNlcHRpb24sIEludGVycnVwdGVkRXhjZXB0aW9uIHsKICAgICAgICBXYXRjaFNlcnZpY2Ugd2F0Y2hlciA9IEZpbGVTeXN0ZW1zLmdldERlZmF1bHQoKS5uZXdXYXRjaFNlcnZpY2UoKTsKICAgICAgICBQYXRoIHBhdGggPSBGaWxlU3lzdGVtcy5nZXREZWZhdWx0KCkuZ2V0UGF0aCgiL2hvbWUiLCAidnB1cGtpbiIpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbihwYXRoLnRvU3RyaW5nKCkpOwogICAgICAgIFdhdGNoS2V5IGtleSA9CiAgICAgICAgICAgICAgICBwYXRoLnJlZ2lzdGVyKHdhdGNoZXIsIEVOVFJZX0NSRUFURSwgRU5UUllfREVMRVRFLCBFTlRSWV9NT0RJRlkpOwogICAgICAgIFRocmVhZCB0ID0gbmV3IFRocmVhZCgoKSAtPiB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgIFdhdGNoS2V5IHdhdGNoS2V5ID0gbnVsbDsKICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgd2F0Y2hLZXkgPSB3YXRjaGVyLnRha2UoKTsKICAgICAgICAgICAgICAgIH0gY2F0Y2ggKEludGVycnVwdGVkRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmb3IgKFdhdGNoRXZlbnQ8Pz4gZXZlbnQgOiB3YXRjaEtleS5wb2xsRXZlbnRzKCkpIHsKICAgICAgICAgICAgICAgICAgICBXYXRjaEV2ZW50LktpbmQ8Pz4ga2luZCA9IGV2ZW50LmtpbmQoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoa2luZCA9PSBPVkVSRkxPVykgewogICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgV2F0Y2hFdmVudDxQYXRoPiBldiA9IChXYXRjaEV2ZW50PFBhdGg+KSBldmVudDsKICAgICAgICAgICAgICAgICAgICBQYXRoIGZpbGVuYW1lID0gZXYuY29udGV4dCgpOwogICAgICAgICAgICAgICAgICAgIFBhdGggY2hpbGQgPSBwYXRoLnJlc29sdmUoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIFN0cmluZyBjb250ZW50VHlwZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudFR5cGUgPSBGaWxlcy5wcm9iZUNvbnRlbnRUeXBlKGNoaWxkKTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChJT0V4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGUucHJpbnRTdGFja1RyYWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAobnVsbCA9PSBjb250ZW50VHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIk51bGwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghY29udGVudFR5cGUuZXF1YWxzKCJ0ZXh0L3BsYWluIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgU3lzdGVtLmVyci5mb3JtYXQoIk5ldyBmaWxlICclcyciICsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIGlzIG5vdCBhIHBsYWluIHRleHQgZmlsZS4lbiIsIGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQuZm9ybWF0KCJFbWFpbGluZyBmaWxlICVzJW4iLCBmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBib29sZWFuIHZhbGlkID0ga2V5LnJlc2V0KCk7CiAgICAgICAgICAgICAgICBpZiAoIXZhbGlkKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IHdoaWxlICh0cnVlKTsKICAgICAgICB9KTsKICAgICAgICB0LnN0YXJ0KCk7CiAgICAgICAgU2Nhbm5lciBzYyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgU3RyaW5nIG5leHQ7CiAgICAgICAgZG8gewogICAgICAgICAgICBuZXh0ID0gc2MubmV4dCgpOwogICAgICAgIH0gd2hpbGUgKCFuZXh0LmVxdWFscygic3RvcCIpKTsKICAgICAgICB0LmludGVycnVwdCgpOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiQnllISIpOwogICAgfQp9Cg==
compilation info
Main.java:9: error: class App is public, should be declared in a file named App.java
public class App {
^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
stdout