Created
August 31, 2013 02:37
-
-
Save Kurt-P/6395903 to your computer and use it in GitHub Desktop.
Open an existing input file and copy it to non-existing output file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class jcopy { | |
public static void main(String[] args) throws IOException { | |
BufferedReader stdin = new BufferedReader( new InputStreamReader(System.in)); | |
System.out.println("enter Input File Name: "); | |
String InputFile = stdin.readLine(); | |
File infile = new File(InputFile); | |
InputStream fin = new FileInputStream(infile); | |
System.out.println("enter Outut File Name: "); | |
String OutputFile = stdin.readLine(); | |
File outfile = new File(OutputFile); | |
OutputStream fout = new FileOutputStream(outfile); | |
int len; | |
byte[] buf = new byte[1024]; | |
while ((len = fin.read(buf)) > 0) { | |
fout.write(buf, 0, len); | |
} | |
fin.close(); | |
fout.close(); | |
System.out.println("copied " + InputFile + " to " + OutputFile); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment