It is necessary that when choosing an image it moves to the root folder of the program, how can this be implemented? I tried through Files.copy and Files.create (), but the second one needs some strange arguments.

    2 answers 2

    import static java.nio.file.StandardCopyOption.*; ... Files.move(source, target, REPLACE_EXISTING); 

    If the target file already exists, the source overwrite it.

    or

     Files.move(source, target); 

    If the target file already exists, the source will not be moved.

    Documentation: one , two .

    • And if I need to move without changing the file? - gg ff
    • What does it mean without changing the file? - Enikeyschik
    • In order not to replace an existing file with a new one, just move it without replacing anything - gg ff
    • I still do not understand, but you can. Give the file a different name. - Enikeyschik
    • Ok, now I'll try! - gg ff

    Try the following:

      Files.copy(изначальныйПутьФайла, новыйПутьФайла, StandardCopyOption.REPLACE_EXISTING);