Example usage for java.nio.file FileSystems getDefault

List of usage examples for java.nio.file FileSystems getDefault

Introduction

In this page you can find the example usage for java.nio.file FileSystems getDefault.

Prototype

public static FileSystem getDefault() 

Source Link

Document

Returns the default FileSystem .

Usage

From source file:cpd3314.project.CPD3314ProjectTest.java

@Test
public void testFormatXML() throws Exception {
    System.out.println("main");
    String[] args = { "-format=XML" };
    CPD3314Project.main(args);/*from w  w w .j  a  v  a  2 s . c  o  m*/
    File expected = FileSystems.getDefault().getPath("testFiles", "formatXML.xml").toFile();
    File result = new File("CPD3314.xml");
    assertTrue("Output File Doesn't Exist", result.exists());
    assertXMLFilesEqual(expected, result);
}

From source file:com.spankingrpgs.util.LoadStateUtils.java

/**
 * Given a Loader, and a path to data files, loads the data from the files into the game using the loader.
 *
 * @param loader  The loader to use to load data into the game
 * @param dataPath  The path containing the files containing the data to load
 * @param fileGlob  A glob that describes the kinds of files to load
 * @param newLineMarker  The String to use to represent new lines
 *///from ww  w  .j  a v a  2 s  .  co  m
public static void loadData(Loader loader, Path dataPath, String fileGlob, String newLineMarker) {
    LOG.info(String.format("Loading %s", dataPath));
    try {
        PathMatcher jsonMatcher = FileSystems.getDefault().getPathMatcher(fileGlob);
        Collection<String> data = StreamSupport.stream(Files.newDirectoryStream(dataPath).spliterator(), false)
                .peek(path -> LOG.fine(String.format("Loading data from %s", path)))
                .filter(jsonMatcher::matches).map((Path path) -> {
                    try {
                        return String.join(newLineMarker, Files.readAllLines(path));
                    } catch (IOException e) {
                        String msg = String.format("Problem reading file: %s", path);
                        LOG.log(Level.SEVERE, String.format("%s with exception:%s", msg, e), e);
                        throw new RuntimeException(msg);
                    }
                }).collect(Collectors.toList());
        loader.load(data, GameState.getCleanInstance());
    } catch (IOException exception) {
        String msg = String.format("Problem reading files in: %s", dataPath);
        LOG.log(Level.SEVERE, String.format("%s with exception: %s", msg, exception), exception);
        throw new RuntimeException(msg);
    }
}

From source file:us.colloquy.sandbox.FileProcessor.java

@Test
public void listAllUzipedFilesContent() {
    ///Documents/Tolstoy/diaries

    Path pathToLetters = FileSystems.getDefault()
            .getPath(System.getProperty("user.home") + "/Documents/Tolstoy/unzipLetters");

    List<Path> results = new ArrayList<>();

    int maxDepth = 6;

    try (Stream<Path> stream = Files.find(pathToLetters, maxDepth, (path, attr) -> {
        return String.valueOf(path).endsWith(".opf");
    })) {//  w  w w  .  j a va2 s .  c om

        stream.forEach(results::add);

        //            String joined = stream
        //                    .sorted()
        //                    .map(String::valueOf)
        //                    .collect(Collectors.joining("; "));
        //
        //            System.out.println("\nFound: " + joined);

    } catch (IOException e) {
        e.printStackTrace();
    }

    System.out.println("files: " + results.size());

    Set<String> uriList = new TreeSet<>();

    try {

        for (Path res : results) {
            Path parent = res.getParent();

            System.out.println("---------------------------------------------");
            System.out.println(parent.toString());
            //use jsoup to list all files that contain something useful
            Document doc = Jsoup.parse(res.toFile(), "UTF-8");

            for (Element element : doc.getElementsByTag("dc:title")) {
                //Letter letter = new Letter();

                // StringBuilder content = new StringBuilder();
                System.out.println(element.text());

                //                    for (Element child : element.children())
                //                    {
                //                       System.out.println(child.tagName() + "\t" + child.text());
                //                    }
            }

            //                for (Element element : doc.getElementsByTag("navPoint"))
            //                {
            //                    //Letter letter = new Letter();
            //
            //                    // StringBuilder content = new StringBuilder();
            //
            //                    for (Element child : element.children())
            //                    {
            //                        String label = child.text();
            //
            //                        if (StringUtils.isNotEmpty(label))
            //                        {
            //                            if (label.matches("?"))
            //                            {
            //                                System.out.println("------------------");
            //                            }
            //
            //
            //                            String url = child.getElementsByTag("content").attr("src");
            //
            //                            if (label.matches(".*\\d{1,3}.*[?--?]+.*") &&
            //                                    StringUtils.isNotEmpty(url) )
            //                            {
            //
            //                                uriList.add(parent.toString()
            //                                        + File.separator + url.replaceAll("#.*",""));
            ////                                System.out.println("nav point: " + label + " src " + parent.toString()
            ////                                        + System.lineSeparator() + url.replaceAll("#.*",""));
            //
            //
            //                            } else
            //                            {
            //                                // System.out.println("nav point: " + label + " src " + child.getElementsByTag("content").attr("src"));
            //                            }
            //
            //
            //                        }
            //                    }
            //                }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    System.out.println("Size: " + uriList.size());

    for (String uri : uriList) {
        //parse and
        System.out.println(uri);
    }

}

From source file:uk.org.openeyes.diagnostics.FhirUtils.java

/**
 * @param type/*from  ww w  .  j a  v a 2  s .com*/
 * @param media
 * @param attachments
 */
public Media createMedia(File media) throws IOException {
    Media m = Media.Factory.newInstance();
    Attachment att = m.addNewContent();
    Base64Binary data = att.addNewData();

    Path path = FileSystems.getDefault().getPath(media.getParentFile().getAbsolutePath(), media.getName());
    att.addNewContentType().setValue(Files.probeContentType(path));
    att.addNewTitle().setValue(media.getName());
    data.setValue(this.base64encode(media));
    att.setData(data);
    m.addNewSubject().addNewReference().setValue("media/med-1");
    MediaDocument doc = MediaDocument.Factory.newInstance();
    doc.setMedia(m);
    return m;
}

From source file:org.assertj.examples.PathAssertionsExamples.java

@Test
public void path_rwx_assertion() throws Exception {
    assumeTrue(SystemUtils.IS_OS_UNIX);//from  w  w  w . ja v a2  s . c o  m

    // Create a file and set permissions to be readable by all.
    write(rwxFile, "rwx file".getBytes());

    // using PosixFilePermission to set file permissions 777
    Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
    // add owners permission
    perms.add(PosixFilePermission.OWNER_READ);
    perms.add(PosixFilePermission.OWNER_WRITE);
    perms.add(PosixFilePermission.OWNER_EXECUTE);
    // add group permissions
    perms.add(PosixFilePermission.GROUP_READ);
    perms.add(PosixFilePermission.GROUP_WRITE);
    perms.add(PosixFilePermission.GROUP_EXECUTE);
    // add others permissions
    perms.add(PosixFilePermission.OTHERS_READ);
    perms.add(PosixFilePermission.OTHERS_WRITE);
    perms.add(PosixFilePermission.OTHERS_EXECUTE);

    Files.setPosixFilePermissions(rwxFile, perms);

    final Path symlinkToRwxFile = FileSystems.getDefault().getPath("symlink-to-rwxFile");
    if (!Files.exists(symlinkToRwxFile)) {
        createSymbolicLink(symlinkToRwxFile, rwxFile);
    }

    // The following assertions succeed:
    assertThat(rwxFile).isReadable().isWritable().isExecutable();

    assertThat(symlinkToRwxFile).isReadable().isWritable().isExecutable();
}

From source file:platform.tooling.support.Runner.java

private Result installRemoteTool(Result result) {
    // download/*from  www  .ja  va2 s . c o m*/
    var version = request.getVersion();
    var toolArchive = tool.computeArchive(version);
    var toolUri = tool.computeUri(version);
    var toolArchivePath = toolPath.resolve(toolArchive);
    if (Files.notExists(toolArchivePath)) {
        var timeout = (int) TimeUnit.MILLISECONDS.convert(9, TimeUnit.SECONDS);
        try {
            FileUtils.copyURLToFile(toolUri.toURL(), toolArchivePath.toFile(), timeout, timeout);
        } catch (IOException e) {
            throw new UncheckedIOException("Loading tool failed: " + toolUri, e);
        }
    }

    // extract
    var jarTool = ToolProvider.findFirst("jar").orElseThrow();
    var stringWriter = new StringWriter();
    var printWriter = new PrintWriter(stringWriter);
    jarTool.run(printWriter, printWriter, "--list", "--file", toolArchivePath.toString());
    var toolFolderName = stringWriter.toString().split("\\R")[0];
    var toolFolderPath = toolPath.resolve(toolFolderName);
    if (Files.notExists(toolFolderPath)) {
        try {
            jarTool.run(System.out, System.err, "--extract", "--file", toolArchivePath.toString());
            FileUtils.moveDirectoryToDirectory(Paths.get(toolFolderName).toFile(), toolPath.toFile(), true);
        } catch (IOException e) {
            throw new UncheckedIOException("Extracting tool failed: " + toolUri, e);
        }
    }
    result.toolHome = toolFolderPath.normalize().toAbsolutePath();

    // compute program entry point
    var executable = toolFolderPath.resolve(tool.computeExecutablePath());
    if (FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
        executable.toFile().setExecutable(true);
    }
    result.toolExecutable = executable;
    return result;
}

From source file:org.n52.movingcode.runtime.coderepository.LocalVersionedFileRepository.java

private final synchronized void reloadContent() {

    PackageInventory newInventory = new PackageInventory();

    // obtain all immediate subfolders
    Path repoRoot = FileSystems.getDefault().getPath(directory.getAbsolutePath());
    Collection<Path> packageFolders = listSubdirs(repoRoot);

    LOGGER.info("Scanning directory: " + directory.getAbsolutePath());

    for (Path currentFolder : packageFolders) {

        // attempt to read packageDescription XML
        File packageDescriptionFile = new File(currentFolder.toFile(), Constants.PACKAGE_DESCRIPTION_XML);
        // deal with empty inventory folders
        if (!packageDescriptionFile.exists()) {
            // TODO: remove such invalid folders?
            LOGGER.warn("Found empty inventory folder: " + currentFolder.toAbsolutePath());
            continue; // skip this and immediately jump to the next iteration
        }//from   ww  w . j  a v  a 2  s .c  o  m

        PackageDescriptionDocument pd;
        try {
            pd = PackageDescriptionDocument.Factory.parse(packageDescriptionFile);
        } catch (XmlException e) {
            // silently skip this and immediately jump to the next iteration
            continue;
        } catch (IOException e) {
            // silently skip this and immediately jump to the next iteration
            continue;
        }

        // packageID = absolute path
        LOGGER.info(
                "Found package: " + currentFolder + "; using ID: " + RepositoryUtils.extractId(pd).toString());

        // attempt to access workspace root folder
        String workspace = pd.getPackageDescription().getWorkspace().getWorkspaceRoot();
        if (workspace.startsWith("./")) {
            workspace = workspace.substring(2); // remove leading "./" if it exists
        }

        File workspaceDir = new File(currentFolder.toFile(), workspace);
        if (!workspaceDir.exists()) {
            continue; // skip this and immediately jump to the next iteration
        }

        MovingCodePackage mcPackage = new MovingCodePackage(workspaceDir, pd);

        // validate
        // and add to package map
        // and add current file to zipFiles map
        if (mcPackage.isValid()) {
            newInventory.add(mcPackage);
            LOGGER.info(
                    "Found package: " + currentFolder + "; using ID: " + mcPackage.getPackageId().toString());
        } else {
            LOGGER.error(currentFolder + " is an invalid package.");
        }
    }

    // announce new content scan
    updateInventory(newInventory);
}

From source file:com.samsung.sjs.Compiler.java

@SuppressWarnings("static-access")
public static void main(String[] args) throws IOException, SolverException, InterruptedException {
    boolean debug = false;
    boolean use_gc = true;
    CompilerOptions.Platform p = CompilerOptions.Platform.Native;
    CompilerOptions opts = null;//w ww.  j a  v a  2  s .c  o m
    boolean field_opts = false;
    boolean typecheckonly = false;
    boolean showconstraints = false;
    boolean showconstraintsolution = false;
    String[] decls = null;
    String[] links = null;
    String[] objs = null;
    boolean guest = false;
    boolean stop_at_c = false;
    String external_compiler = null;
    boolean encode_vals = false;
    boolean x32 = false;
    boolean validate = true;
    boolean interop = false;
    boolean boot_interop = false;
    boolean oldExpl = false;
    String explanationStrategy = null;
    boolean efl = false;

    Options options = new Options();
    options.addOption("debugcompiler", false, "Enable compiler debug spew");
    //options.addOption("o", true, "Set compiler output file (must be .c)");
    options.addOption(OptionBuilder //.withArgName("o")
            .withLongOpt("output-file").withDescription("Output file (must be .c)").hasArg().withArgName("file")
            .create("o"));
    options.addOption(OptionBuilder.withLongOpt("target")
            .withDescription("Select target platform: 'native' or 'web'").hasArg().create());
    options.addOption(OptionBuilder.withLongOpt("gc")
            .withDescription("Disable GC: param is 'on' (default) or 'off'").hasArg().create());

    options.addOption(OptionBuilder
            .withDescription("Enable field access optimizations: param is 'true' (default) or 'false'").hasArg()
            .create("Xfields"));

    options.addOption(OptionBuilder
            .withDescription("Compile for encoded values.  TEMPORARY.  For testing interop codegen").hasArg()
            .create("XEncodedValues"));

    options.addOption(OptionBuilder.withLongOpt("typecheck-only")
            .withDescription("Only typecheck the file, don't compile").create());
    options.addOption(OptionBuilder.withLongOpt("show-constraints")
            .withDescription("Show constraints generated during type inference").create());
    options.addOption(OptionBuilder.withLongOpt("show-constraint-solution")
            .withDescription("Show solution to type inference constraints").create());
    options.addOption(OptionBuilder.withLongOpt("extra-decls")
            .withDescription("Specify extra declaration files, comma-separated").hasArg()
            .withValueSeparator(',').create());
    options.addOption(OptionBuilder.withLongOpt("native-libs")
            .withDescription("Specify extra linkage files, comma-separated").hasArg().withValueSeparator(',')
            .create());
    Option extraobjs = OptionBuilder.withLongOpt("extra-objs")
            .withDescription("Specify extra .c/.cpp files, comma-separated").hasArg().withValueSeparator(',')
            .create();
    extraobjs.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(extraobjs);
    options.addOption(OptionBuilder.withLongOpt("guest-runtime")
            .withDescription(
                    "Emit code to be called by another runtime (i.e., main() is written in another language).")
            .create());
    options.addOption(OptionBuilder.withLongOpt("only-c")
            .withDescription("Generate C code, but do not attempt to compile it").create());
    options.addOption(OptionBuilder.withLongOpt("c-compiler")
            .withDescription("Disable GC: param is 'on' (default) or 'off'").hasArg().create("cc"));
    options.addOption(OptionBuilder.withLongOpt("runtime-src")
            .withDescription("Specify path to runtime system source").hasArg().create());
    options.addOption(OptionBuilder.withLongOpt("ext-path")
            .withDescription("Specify path to external dependency dir (GC, etc.)").hasArg().create());
    options.addOption(OptionBuilder.withLongOpt("skip-validation")
            .withDescription("Run the backend without validating the results of type inference").create());

    options.addOption(OptionBuilder.withLongOpt("m32").withDescription("Force 32-bit compilation").create());
    options.addOption(OptionBuilder.withLongOpt("Xbootinterop")
            .withDescription("Programs start with global interop dirty flag set (experimental)").create());
    options.addOption(OptionBuilder.withLongOpt("Xinterop")
            .withDescription("Enable (experimental) interoperability backend").create());

    options.addOption(OptionBuilder.withDescription("C compiler default optimization level").create("O"));
    options.addOption(OptionBuilder.withDescription("C compiler optimization level 0").create("O0"));
    options.addOption(OptionBuilder.withDescription("C compiler optimization level 1").create("O1"));
    options.addOption(OptionBuilder.withDescription("C compiler optimization level 2").create("O2"));
    options.addOption(OptionBuilder.withDescription("C compiler optimization level 3").create("O3"));

    options.addOption(
            OptionBuilder.withLongOpt("oldExpl").withDescription("Use old error explanations").create());

    String explanationStrategyHelp = "default: " + FixingSetFinder.defaultStrategy() + "; other choices: "
            + FixingSetFinder.strategyNames().stream().filter(s -> !s.equals(FixingSetFinder.defaultStrategy()))
                    .collect(Collectors.joining(", "));

    options.addOption(OptionBuilder.withLongOpt("explanation-strategy")
            .withDescription("Error explanation strategy to use (" + explanationStrategyHelp + ')').hasArg()
            .create());

    options.addOption(
            OptionBuilder.withLongOpt("efl").withDescription("Set up efl environment in main()").create());

    try {
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(options, args);

        String[] newargs = cmd.getArgs();
        if (newargs.length != 1) {
            throw new ParseException("Invalid number of arguments");
        }

        String sourcefile = newargs[0];
        if (!sourcefile.endsWith(".js")) {
            throw new ParseException("Invalid file extension on input file: " + sourcefile);
        }

        String gc = cmd.getOptionValue("gc", "on");
        if (gc.equals("on")) {
            use_gc = true;
        } else if (gc.equals("off")) {
            use_gc = false;
        } else {
            throw new ParseException("Invalid GC option: " + gc);
        }
        String fields = cmd.getOptionValue("Xfields", "true");
        if (fields.equals("true")) {
            field_opts = true;
        } else if (fields.equals("false")) {
            field_opts = false;
        } else {
            throw new ParseException("Invalid field optimization option: " + fields);
        }
        String encoding = cmd.getOptionValue("XEncodedValues", "false");
        if (encoding.equals("true")) {
            encode_vals = true;
        } else if (encoding.equals("false")) {
            encode_vals = false;
        } else {
            throw new ParseException("Invalid value encoding option: " + encode_vals);
        }
        String plat = cmd.getOptionValue("target", "native");
        if (plat.equals("native")) {
            p = CompilerOptions.Platform.Native;
        } else if (plat.equals("web")) {
            p = CompilerOptions.Platform.Web;
        } else {
            throw new ParseException("Invalid target platform: " + plat);
        }
        if (cmd.hasOption("cc")) {
            external_compiler = cmd.getOptionValue("cc");
        }
        if (cmd.hasOption("skip-validation")) {
            validate = false;
        }
        if (cmd.hasOption("typecheck-only")) {
            typecheckonly = true;
        }
        if (cmd.hasOption("show-constraints")) {
            showconstraints = true;
        }
        if (cmd.hasOption("show-constraint-solution")) {
            showconstraintsolution = true;
        }
        if (cmd.hasOption("debugcompiler")) {
            debug = true;
        }
        if (cmd.hasOption("m32")) {
            x32 = true;
        }
        if (cmd.hasOption("Xinterop")) {
            interop = true;
        }
        if (cmd.hasOption("Xbootinterop")) {
            boot_interop = true;
            if (!interop) {
                System.err.println("WARNING: --Xbootinterop enabled without --Xinterop (no effect)");
            }
        }
        if (cmd.hasOption("oldExpl")) {
            oldExpl = true;
        }
        if (cmd.hasOption("explanation-strategy")) {
            explanationStrategy = cmd.getOptionValue("explanation-strategy");
        }
        String output = cmd.getOptionValue("o");
        if (output == null) {
            output = sourcefile.replaceFirst(".js$", ".c");
        } else {
            if (!output.endsWith(".c")) {
                throw new ParseException("Invalid file extension on output file: " + output);
            }
        }
        String runtime_src = cmd.getOptionValue("runtime-src");
        String ext_path = cmd.getOptionValue("ext-path");
        if (ext_path == null) {
            ext_path = new File(".").getCanonicalPath() + "/external";
        }

        if (cmd.hasOption("extra-decls")) {
            decls = cmd.getOptionValues("extra-decls");
        }
        if (cmd.hasOption("native-libs")) {
            links = cmd.getOptionValues("native-libs");
        }
        if (cmd.hasOption("extra-objs")) {
            objs = cmd.getOptionValues("extra-objs");
        }
        if (cmd.hasOption("guest-runtime")) {
            guest = true;
        }
        if (cmd.hasOption("only-c")) {
            stop_at_c = true;
        }
        if (cmd.hasOption("efl")) {
            efl = true;
        }

        int coptlevel = -1; // default optimization
        if (cmd.hasOption("O3")) {
            coptlevel = 3;
        } else if (cmd.hasOption("O2")) {
            coptlevel = 2;
        } else if (cmd.hasOption("O1")) {
            coptlevel = 1;
        } else if (cmd.hasOption("O0")) {
            coptlevel = 0;
        } else if (cmd.hasOption("O")) {
            coptlevel = -1;
        } else {
            coptlevel = 3;
        }

        if (!Files.exists(Paths.get(sourcefile))) {
            System.err.println("File " + sourcefile + " was not found.");
            throw new FileNotFoundException(sourcefile);
        }

        String cwd = new java.io.File(".").getCanonicalPath();

        opts = new CompilerOptions(p, sourcefile, debug, output, use_gc,
                external_compiler == null ? "clang" : external_compiler,
                external_compiler == null ? "emcc" : external_compiler, cwd + "/a.out", // emcc automatically adds .js
                new File(".").getCanonicalPath(), true, field_opts, showconstraints, showconstraintsolution,
                runtime_src, encode_vals, x32, oldExpl, explanationStrategy, efl, coptlevel);
        if (guest) {
            opts.setGuestRuntime();
        }
        if (interop) {
            opts.enableInteropMode();
        }
        if (boot_interop) {
            opts.startInInteropMode();
        }
        opts.setExternalDeps(ext_path);
        if (decls != null) {
            for (String s : decls) {
                Path fname = FileSystems.getDefault().getPath(s);
                opts.addDeclarationFile(fname);
            }
        }
        if (links != null) {
            for (String s : links) {
                Path fname = FileSystems.getDefault().getPath(s);
                opts.addLinkageFile(fname);
            }
        }
        if (objs == null) {
            objs = new String[0];
        }

    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("sjsc", options);
    }

    if (opts != null) {
        // This typechecks, and depending on flags, also generates C
        compile(opts, typecheckonly, validate); // don't worry about type validation on command line for now
        if (!typecheckonly && !stop_at_c) {
            int ret = 0;
            // Kept around for debugging 32-bit...
            if (p == CompilerOptions.Platform.Native) {
                if (opts.m32()) {
                    String[] x = new String[2];
                    x[0] = "-m32";
                    x[1] = opts.getExternalDeps() + "/gc/x86/lib/libgc.a";
                    ret = clang_compile(opts, objs, x);
                } else {
                    ret = clang_compile(opts, objs, new String[0]);
                }
            } else {
                ret = emcc_compile(opts, objs, new String[0]);
            }
            // If clang failed, propagate the failure outwards
            if (ret != 0) {
                System.exit(ret);
            }
        }
    }
}

From source file:cpd3314.project.CPD3314ProjectTest.java

@Test
public void testFormatJSON() throws Exception {
    System.out.println("main");
    String[] args = { "-format=JSON" };
    CPD3314Project.main(args);/*  www .  j  a  v  a 2  s  . c o  m*/
    File expected = FileSystems.getDefault().getPath("testFiles", "formatJSON.json").toFile();
    File result = new File("CPD3314.json");
    assertTrue("Output File Doesn't Exist", result.exists());
    assertJSONFilesEqual(expected, result);
}

From source file:com.aspc.cms.module.SyncResourceApp.java

private void monitorDir() throws Exception {
    // Create a new Watch Service
    WatchService watchService = FileSystems.getDefault().newWatchService();

    registerDir(watchService, syncDirectory);

    while (true) {
        try {/*from www  . jav  a  2 s .c  om*/
            // Obtaining watch keys
            final WatchKey key = watchService.take();//poll(5, TimeUnit.SECONDS);

            if (key == null)
                continue;

            long tmpLastModified = lastModify.get();
            long startLastModified = tmpLastModified;
            try {
                // key value can be null if no event was triggered
                for (WatchEvent<?> watchEvent : key.pollEvents()) {
                    final Kind<?> kind = watchEvent.kind();
                    // Overflow event
                    if (StandardWatchEventKinds.OVERFLOW == kind) {
                        continue; // loop
                    }

                    tmpLastModified = scanChanges(syncDirectory, tmpLastModified);
                }
            } finally {
                key.reset();
            }
            lastModify.compareAndSet(startLastModified, tmpLastModified);
        } catch (Exception e) {
            LOGGER.warn("could not send", e);
            Thread.sleep(60000);
        }
    }
}