Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java question. Write a method public static void copy(String infile, String outfile) that copies all bytes from one file to another, without using Files.copy. Using
java question. Write a method public static void copy(String infile, String outfile) that copies all bytes from one file to another, without using Files.copy. Using copydemo.java and london.txt provided to test.
import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; /** This program tests a method that copies all bytes from one file to another, without using Files.copy. */ //OUT londonOut.txt public class CopyDemo { public static void main(String[] args) { try { Scanner cin = new Scanner(System.in); System.out.print("Enter the name of the source file -> "); String infile = cin.next(); System.out.print("Enter the name of the destination file -> "); String outfile = cin.next(); copy(infile,outfile); } catch (IOException ex) { System.out.println(ex); } } /** Copies a source file to a destination file. @param infile the name of the input/source file @param outfile the name of the output/destination file @throws java.io.FileNotFoundException */ public static void copy(String infile, String outfile) throws FileNotFoundException, IOException { //complete this method } }
london.txt
London Bridge is falling down, Falling down, falling down, London Bridge is falling down, My fair Lady.
Build it up with wood and clay, Wood and clay, wood and clay, Build it up with wood and clay, My fair Lady
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started