[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Copy/Move program using Java

Posted on 1998-07-19
2
Medium Priority
?
217 Views
Last Modified: 2010-03-30
Could anybody suggest me please to write Copy and Move programs for copying and moving files from one directory to another?, these programs should work like dos/windows copy and move commands.
I use Win95, jdk1.2bata3
0
Comment
Question by:hvhemant
2 Comments
 
LVL 2

Accepted Solution

by:
threshold earned 20 total points
ID: 1227087
Moving files is easy in Java. Try java.io.File.rename(File)... to specify the pathname to perform the moving of file.

Copying is more difficult, you can open a FileInputStream and a FileOutputStream to copy a file.

Or use the java.lang.Runtime.exec(...) to excute DOS command in new Process, it's more easy in Java Application.
0
 
LVL 1

Expert Comment

by:dryang
ID: 1227088
"..these programs should work like dos/windows copy and move commands. "

use the 'argv' string arry to help you manupilate your texxt commands
eg
public static void main(String argv[ ])
                                                     ^-this one...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month17 days, 17 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question