Java : AtomicMoveNotSupportedException con ejemplos

AtomicMoveNotSupportedException (Java SE 23 & JDK 23) en Java con ejemplos.
Encontrará muestras de código para la mayoría de los métodos AtomicMoveNotSupportedException.

Nota :


Summary

Se lanza una excepción marcada cuando no se puede mover un archivo como una operación del sistema de archivos atómico. (Traducción automática)

Class diagram

System.out.println(System.getProperty("os.name")); // Windows 11

final var source = Path.of("D:", "java-work", "src.txt");
System.out.println(source); // D:\java-work\src.txt

final var target = Path.of("R:", "java-work", "dst.txt");
System.out.println(target); // R:\java-work\dst.txt

Files.createFile(source);

System.out.println(Files.exists(source)); // true
System.out.println(Files.exists(target)); // false

try {
    Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
} catch (AtomicMoveNotSupportedException e) {
    System.out.println("AtomicMoveNotSupportedException!");
}

// Result
// ↓
//AtomicMoveNotSupportedException!

Constructors

AtomicMoveNotSupportedException (String source, String target, String reason)

Construye una instancia de esta clase. (Traducción automática)

final var e = new AtomicMoveNotSupportedException("aaa.txt", "bbb.txt", "Reason!");
System.out.println(e); // java.nio.file.AtomicMoveNotSupportedException: aaa.txt -> bbb.txt: Reason!
System.out.println(e.getFile()); // aaa.txt
System.out.println(e.getOtherFile()); // bbb.txt
System.out.println(e.getReason()); // Reason!

Methods declared in FileSystemException

getFile, getMessage, getOtherFile, getReason

Consulte el siguiente enlace.

Methods declared in Throwable

addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

Consulte el siguiente enlace.


Related posts

To top of page