Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:27:14+00:00 2026-06-09T12:27:14+00:00

I am Trying to Copy Single file from Source to Destination using Java but

  • 0

I am Trying to Copy Single file from Source to Destination using Java but getting following Error message.

java.io.FileNotFoundException: Following is the method

public void copy_single(String source,String dest,String filename)
{
  try
  { System.out.println(source + "" + filename);
    System.out.println(dest + "" + filename);
    File inputFile = new File(source+""+filename);
    File outputFile = new File(dest+""+filename);
    Process proc0 = Runtime.getRuntime().exec("chmod -R 777 "+inputFile+"");
    proc0.waitFor();
    Process proc1 = Runtime.getRuntime().exec("chmod -R 777 "+outputFile+"");
    proc1.waitFor();
    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    int c;
    while ((c = in.read()) != -1)
      out.write(c);
    in.close();
    out.close();
  } catch(Exception e) {
    e.printStackTrace();
    System.out.println("Error: Operation failed!");
  }
}

Output:-

/home/root/Tool/AAputDelta.sh
/home/root/Desktop/Sqa/BaseLine/Engine/AAputDelta.sh
java.io.FileNotFoundException: /home/root/Desktop/Sqa/BaseLine/Engine/AAputDelta.sh (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
at java.io.FileOutputStream.<init>(FileOutputStream.java:145)

How to copy simple file using java.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:27:16+00:00Added an answer on June 9, 2026 at 12:27 pm

    Use apache commons FileUtils. Any of these should be sufficient

    FileUtils.copyFile(File srcFile, File destFile) 
    FileUtils.copyFile(File srcFile, File destFile, boolean preserveFileDate) 
    FileUtils.copyFileToDirectory(File srcFile, File destDir) 
    FileUtils.copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read a single file from a java.util.zip.ZipInputStream , and copy
I'm trying copy a single file from the Plugin directory inside of my Wordpress
I am trying to copy all format file (.txt,.pdf,.doc ...) file from source folder
Hi I'm trying to use robocopy to copy a single file from my computer
I'm trying to copy a single file using copy-item to a remote computer using
I'm trying to copy a single file from CVS into a new project that
I'm currently trying to copy data from table into another by using a SELECT
I am trying to move a single file (call it foo.txt) from one repository
I am trying use std::copy to copy from two different iterator. But during course
I'm trying to copy multiple files from a deep source tree that have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.