Skip to content

Codes #286

@siddharthrgade21-a11y

Description

@siddharthrgade21-a11y

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.io.IOException;

public class FileCopyExample {
public static void main(String[] args) {
Path source = Paths.get("source.txt");
Path target = Paths.get("destination.txt");

    try {
        // Replaces the target file if it already exists
        Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
        System.out.println("File copied successfully!");
    } catch (IOException e) {
        e.printStackTrace();
    }
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions