Home Tutorialhelp Comment this is the correct program

 
 

Comment

madhan
this is the correct program,
November 6, 2008 at 11:17 PM

import java.io.*;
import java.nio.*;

public class file2{
public static void main(String[] args) throws IOException
{

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the source directory or file name : ");
String source = in.readLine();
File src = new File(source);
System.out.println("Enter the destination directory or file name : ");
String destination = in.readLine();
File dst = new File(destination);
copyDirectory(src, dst);
}

public static void copyDirectory(File srcPath, File dstPath) throws IOException
{
if (srcPath.isDirectory())
{
if (!dstPath.exists())
{
dstPath.mkdir();
}

String files[] = srcPath.list();
for(int i = 0; i < files.length; i++)
{
copyDirectory(new File(srcPath, files[i]), new File(dstPath, files[i]));
}
}
else
{
if(!srcPath.exists())
{
System.out.println("File or directory does not exist.");
System.exit(0);
}
else
{
InputStream in = new FileInputStream(srcPath);
OutputStream out = new FileOutputStream(dstPath);

// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}
System.out.println("Directory copied.");
}
}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

io
io  write a program in java to accept a filename from user and print its content on the monitor   Hello Friend, Try the following code: import java.io.*; import java.util.*; class DisplayContentOfFile { public 

Java Beginners

IO in java
IO in java  Your search mechanism will take as input a multi-word... the words specified appear closer to one another. For example, if you search..., document 1 would be given higher weight. 2. Your program will take as input 

Java Beginners

java binary file io example
java binary file io example  java binary file io example 

Java Beginners

io
io  create a meanu based text editor in java having features of creating file,viewing file,deleting file,renaming file,copying file and cutting file 

Java Beginners

java IO
java IO  Write a Java program to accept a file name as command line argument. Append the string "File Modified by Programme" to the end of the same file and print the contents of the modified File 

Java Beginners

java io
java io  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits 

Java Beginners

Correct errors - Java Beginners
Correct errors  Identify and correct the errors in the following program: public java Method { public static method1(int n, m) { n += m... Friend, Try the following code: public class Example{ public static void main 

Java Beginners

java IO programing
java IO programing  how Java source file is used as input the program will echo lines 

Java Beginners

IO concept
IO concept  Write a java program that moves the contents of the one file to another and deletes the old file.   Hi Friend, Try...!"); } } For more information, visit the following link: Java Move File Thanks 

Programming Tutorials

Working With File,Java Input,Java Input Output,Java Inputstream,Java io Tutorial,Java io package,Java io example
to the existence of a corresponding file/directory. If the file exist, a program can... (usually where program is located).  File(dirpath,fname)  ...; Lets see an example that checks the existence of  a specified file 

Java Beginners

IO File - Java Beginners
IO File  Write a java program which will read an input file & will produce an output file which will extract errors & warnings. It shall exclude the standard errors & warnings. The standard errors & warnings you can find out 

Java Beginners

java-io - Java Beginners
java-io  Hi Deepak; down core java io using class in myn...://www.roseindia.net/java/java-conversion/two-dimensional-array-program-using-nested-loop.shtml http://www.roseindia.net/java/beginners/SquareMatrix.shtml Thanks 

Java Beginners

Import java IO - Java Beginners
Import java IO  for example i know java IO is for input and output. I am using Netbeans5.5.1. How can i see all the classes related to java IO for example; stream reader, buffer reader 

Java Beginners

java io - Java Beginners
Java IO Streams  What is the Java IO Stream 

Java Beginners

java io
java io  by using java coding how to invoke a particular directory 

Java Interview Questions

Java IO
Java IO  What an I/O filter 

Java-Tutorials

Java IO Path
Java IO Path In this section we will discuss about the Java IO Path. Storage.... These sub folders can contains a file or sub folders and so on. For example... called the delimiter. The file separator varies from O/S to O/S for example 

Java Beginners

io packages - Java Beginners
io packages  How can I add two integers in java using io pacages 

Java-Tutorials

Java FileOutputStream Example
Java FileOutputStream Example In this section we will discuss about the Java IO FileOutputStream. FileOutputStream is a class of java.io package which...) throws IOException Example : Here an example is being given which 

Java Beginners

core java ,io operation,calling methods using switch cases
core java ,io operation,calling methods using switch cases  How to create a dictionary program,providing user inputs using io operations with switch cases and providing different options for searching,editing,storing meanings 

Java Beginners

Free Java Is it correct?
Free Java Is it correct?  Hi, Is Java free? If yes then where I can download? Thanks   Hi, You can download it from http://www.oracle.com/technetwork/java/javase/downloads/index.html Thanks 

JSP Servlet Questions

XML response correct in broser but incorrect in Java
XML response correct in broser but incorrect in Java  Firs of all I... is not correct. In browser shows me (correct): <ENELIT> <GESI>...;/ENELIT> And in Java it prints this (incorrect): <html> <head> 

Java Beginners

java program
java program  write a java program to read a file content into a string object using available and read methods of java bufferedinputstream.   Please visit the following link: http://www.roseindia.net/java/example/java 

Java Beginners

io - Java Beginners
. http://www.roseindia.net/java/ Thanks Amardeep 

Java-Tutorials

Java IO StringWriter
in the Java program. In this example I have created a Java class named...Java IO StringWriter In this section we will discussed about the StringWriter...[]) { String str = "Java StringWriter Example"; try 

Java Beginners

How to read the data in text file seperated by by ',' in java using IO Operations
How to read the data in text file seperated by by ',' in java using IO Operations  in Text file data like raju 45,56,67 ramu 46,65,78 raji... how to write the program 

Java-Tutorials

Java IO Writer
Java IO Writer In this section we will discuss about the Writer class in Java... is created and contains the text written by the Java program. Source code... len) throws IOException Example To demonstrate how to use Writer to write 

Java Beginners

Simple IO Application - Java Beginners
Simple IO Application  Hi, please help me Write a simple Java application that prompts the user for their first name and then their last name. The application should then respond with 'Hello first & last name, what 

Java-Tutorials

Java IO InputStream Example
Java IO InputStream Example In this section we will discuss about the InputStream in Java. An abstract class InputStream is a base class of all the byte...   Example : An example is being given here which demonstrates how 

Java-Tutorials

Java IO PrintWriter
Java IO PrintWriter In this tutorial we will learn about the the PrintWriter... on console. PrintWriter is a character based class which makes the Java program easy... the PrintWriter in the Java applications. In this example I have created 

Java Beginners

java program example - Java Beginners
java program example  can we create java program without static and main?can u plzz explain with an example 

Java-Tutorials

Java IO FilterWriter
Java IO FilterWriter In this example we will discuss about the FilterWriter...(); bw.write("Java IO FilterWriter Example"); System.out.println("Data is written... an example is being given which demonstrates about how to use Java FilterWriter 

Java Beginners

Java Program
Java Program  Problem Statement You are required to play a word-game... which is in it's correct place in the secret-word, and a 'cow' stands for a letter which is present in the secret-word, but not in the correct place. However 

Java Beginners

throws example program java
throws example program java  how to use throws exception in java?   The throws keyword is used to indicate that the method raises..." java.lang.ArithmeticException: / by zero Description:- Here is an example of throws clause. We 

Java-Tutorials

Java IO SequenceInputStream Example
Java IO SequenceInputStream Example In this tutorial we will learn about...; started form the offset 'off'. Example : An example... or concatenate the contents of two files. In this example I have created two text 

Java-Tutorials

Java IO OutputStream
Java IO OutputStream In this section we will read about the OutputStream class...) throws IOException   Example : An example... to the specified file. In this example I have tried to read the stream of one file 

Java Beginners

java program - Java Beginners
information: http://www.roseindia.net/java/example/java/io/java-read-file-line...java program   Use antlr to write a program Grep for searching the input for a word: java Grep word [filename] The program reports the line number 

Java Beginners

Difference between Java IO Class - Java Beginners
Difference between Java IO Class  What is the difference in function between Two set of Stream class as mention below- 1)FileInputStream... information. http://www.roseindia.net/java/ Thanks 

Java Beginners

java program - Java Beginners
java program  this is the code. and i want also to display the corresponding scores of the given name. example u input 2 names and you give scores.so it will output also the 2names with there scores also.the code is correct just 

Java-Tutorials

Java IO StringReader
Java IO StringReader In this section we will discuss about the StringReader... in Java. In this example I have created a Java class named...; String str = "\n Java IO StringReader \n"; try 

Java-Tutorials

Java IO FileReader
Java IO FileReader In this tutorial we will learn about the FileReader class in Java. java.io.FileReader class is used to read the character streams. To read... you about how to use java.io.FileReader. In this example I have created a Java 

Java Beginners

Java Program MY NAME
Java Program MY NAME   Write a class that displays your first name... with the following name (for example, for letter A, public displayLetterA... in the correct order to display your name 

Java-Tutorials

Java IO OutputStreamWriter
"); bw.newLine(); bw.write("Java IO OutputStreamWriter Example...Java IO OutputStreamWriter In this section we will learn about the Java..."); osw = new OutputStreamWriter(os); osw.write("Java IO 

Java-Tutorials

First Java Program Example
First Java Program Example In this section we will discuss about the first java program example. To create a Java program we would be required to create...;. To demonstrate about a Java program I am giving a simple example. Example Here 

Java-Tutorials

Java IO CharArrayReader
Java IO CharArrayReader In this tutorial we will learn about the CharArrayReader class in Java. CharArrayReader class in java.io package provides... the stream of char array. In this example I have created a Java class to read 

Java-Tutorials

Java IO FilterReader
Java IO FilterReader In this section we will learn about the FilterReader class in Java. java.io.FilterReader is an abstract class provides the facility... of characters. Syntax : public long skip(long n) throws IOException Example 

Java-Tutorials

Java IO PipedWriter
Java IO PipedWriter In this tutorial we will learn about the PipedWriter in Java. java.io.PipedWriter writes the characters to the piped output stream.... Syntax : public void write(int c) throws IOException Example Here 

Java Beginners

program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat 

Java-Tutorials

Java Io BufferedWriter
Java IO BufferedWriter In this section we will discuss about the BufferedWriter class in Java. java.io.BufferedWriter class extends the java.io.Writer class... s, int off, int len) throws IOException Example This example explains 

Java-Tutorials

Java IO LineNumberReader
Java IO LineNumberReader In this tutorial we will learn about the LineNumberReader in Java. java.io.LineNumberReader class extends...(long n) throws IOException Example Example for demonstrating about 

Java-Tutorials

Java IO BufferedReader
Java IO BufferedReader In this section we will discuss about the BufferedReader class in Java. BufferedReader class in java.io package is used for read... for example FileReader, InputStreamReader etc. Constructor of BufferedReader 

Java-Tutorials

Java IO Reader
Java IO Reader In this section we will discuss about the Reader class in Java... skip(long n) throws IOException Example : An example of Reader class... and how the characters can be read from the stream. In this example I have created 

Java-Tutorials

Java IO InputStreamReader
Java IO InputStreamReader In this section we will discuss about the InputStreamReader in Java. java.io.InputStreamReader class takes input as a byte... is ready to be read or not. Example A simple example is being given here which 

Spring Framework

Spring IO Platform 1.0.0 Released
Spring IO Platform 1.0.0 Released - Check the new features of this release The Spring IO is platform for developing and building the modern day applications.... The Spring IO is 100% open source system and it is modular. The latest version 

Java-Tutorials

Java IO PipedReader
Java IO PipedReader In this section we will discuss about the PipedReader in Java. java.io.PipedReader reads the characters from pipe. java.io.PipedWriter... boolean ready() throws IOException Example This is a very simple example which 

Java-Tutorials

Java IO PushbackReader
Java IO PushbackReader In this section we will discuss about the PushbackReader class in Java. PushbackReader is a class of java.io package that extends.... In this example I have created a simple Java class named 

Java-Tutorials

Java IO CharArrayWriter
Java IO CharArrayWriter In this tutorial we will learn about the CharArrayWriter in Java. java.io.CharArrayWriter extends the java.io.Writer.... : public void writeTo(Writer out) throws IOException Example This example 

Java-Tutorials

Java ByteArrayOutputStream Example
Java ByteArrayOutputStream Example In this section we will discuss about the Java IO Byte Streams ByteArrayOutputStream. ByteArrayOutputStream... IOException Example : Here an example is being given which will demonstrate you 

Java Beginners

please correct this program
please correct this program  import java.util.Scanner; public class Nam { public static void main (String arg[]) { String[] name={"Aki","Karthi","Tk","Suba","Malu","Buvi","Janu","Sara","Sandy","Abi","Ani","Amu 

Programming Tutorials

Identify correct and incorrect statements or examples about the client's view of exceptions received from an enterprise bean invocation.
Identify correct and incorrect statements or examples about...; Identify correct and incorrect statements or examples about the client's view... interfaces are both Java RMI interfaces, and therefore the throws clauses 

Java Interview Questions

How do I write a correct micro-benchmark in Java?
How do I write a correct micro-benchmark in Java?  How do I write a correct micro-benchmark in Java 

Java Beginners

java program
java program  enter any number and print the number's digits in words. example(enter 123) the output comes(one two three 

Java Beginners

java program
java program  A user will input a sequence of positive integers... integers and prints the cumulative total. for example, if the input is 1 7 2 9, the program should print out 1 8 10 10 EVEN:1 ODD:3 

Java Beginners

Java Program
Java Program  Helle can anyone provide me one example for these question? 1 . Write a method that involves the use of command line parameters and class instantiation. Write a method that processes a file based on given 

PHP Tutorial

PHP GD image gamma correct
running the program you will get the following output 

Java Beginners

Java Program
Java Program for accepting numbers from 1 - 999 and printing them in form of words  Program for accepting numbers from 1 - 999 and printing them in form of words   Java Convert Number to Words The given code accept 

Java Beginners

Java Program
Java Program  How to Write a Java program which read in a number... out in the standard output. The program should be started like this: java... to be read. In this example, the program should create three threads for reading 

Java Beginners

Java Program
Java Program  Hi, please share the code to check, if two strings are permutations of each other in java.   Here is an example that prompts the user to enter two strings in order to check whether they are permutation 

Java Beginners

execution of image example program - Java Beginners
execution of image example program  sir. The example for the demo of image display in java,AwtImage.java,after the execution I can see only the frame used, but not the image to be displayed over it, even after selecting 

Java-Tutorials

Java FileInputStream
Java FileInputStream In this section we will discuss about the Java IO... of bytes. Syntax : public long skip(long n) throws IOException Example : In this example I have created a class named ReadFileInputStream.java 

Java Beginners

what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l 

Java Beginners

java program - Java Beginners
java program  "Helo man&sir can you share or gave me a java code hope... A JAVA CODE.THANKS  Hi friend, Having some doubts on Your...." otherwise; return 2 times first minus "z" Which one is correct 

Java Beginners

Java Program - Java Beginners
Java Program  Hi I'm having trouble with this problem, I keep getting errors. Write a program GuessGame.java that plays the game ?guess the number? as follows: Your program chooses the number to be guessed by selecting 

Java Beginners

java program - Java Beginners
java program  1.Write a program in java to input a sentence and find out how many palindromes are there in the sentence. 2. Write a program in java...; Hi Friend, Try the following codes: 1) Palindrome Example import 

Java Beginners

java program - Java Beginners
java program   Pl. let me know about the keyword 'this' with at least 2 or 3 example programs. pl. let me know the program to multiply 2 matrix.... It helps us to avoid name conflicts. As you can see in the following program 

Java-Tutorials

Command Line Standard Input In Java
Command Line Standard Input In Java In this section we will discuss about the Java IO Standard Input through Command Line. Standard streams, feature.... In this example I have created a Java class named JavaSystemInExample.java into which I 

Java Beginners

JAVA PROGRAM - Java Beginners
JAVA PROGRAM  write a program to find the largest word from given sentence ?(WITHOUT USING tokenizer AND ARRAY) for example- input-- ram is intelligent boy. output will be--intelligent   Hi Friend, Try 

Java Beginners

Java Program - Java Beginners
Java Program  Write a program that detects successive repeated occurrence of a letter in a word. For example, in the word ‚??explanation‚?? letter ‚??a‚?? and ‚??n‚?? occurs twice.  Hi Friend, Successive occurrence 

Java-Tutorials

Read Text from Standard IO
operations on files.  Java also supports three Standard Streams...); Working with Reader classes: Java provides the standard I/O.... For example the constructors of the BufferedReader class shown 

Applet Questions

Java Program - Applet
Java Program  A java program to move a text in applet from right to left.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/applet/SampleBanner.shtml Thanks 

Java Beginners

Java Program - Java Beginners
Java Program  Write a program to input a string and print out... should remain the same as before. Example :- INPUT : WelComE TO School OUTPUT : wELcOMe to sCHOOL Sir, Can we show this program through 

Java Beginners

Program - Java Beginners
Java substring indexof example  Java substring index of example 

Java Beginners

Java Program - Java Beginners
Java Program  Write a program to demonstrate use of Grid Layout. On a frame with grid layout place buttons labeled respectively with the letters from ‚??A to Z‚?? . For example if you click the button labeled Z the message ‚ 

Java Beginners

java program - Java Beginners
java program  Hi Friends i have one small doubt!! code for arry to print some strings with out allowing duplicate Strings?  Hello Go.... for example TreeSet: not allowed duplicate element Rajanikant  Hi 

General

Generics Example Program in Java
Generics Example Program in Java explaining how you use it effectively... the Java Program? The introduction to the Generics is the major step in the Java... in Java code. Generic List Example In this example I will show you how you can 

Java Beginners

Java program - Java Beginners
Java program  Dear maam/Sir, I am a 2nd year Computer programming student and we are given an assignment, a program that will show this given output: Example: Enter your Birthday: August 24, 1991 Your Zodiac 

Java Beginners

java program - Java Beginners
://www.roseindia.net/java/example/java/swing/ Thanks Amardeep...java program  ahm... i will use a table, text field and a button in java... a user will input a data to be search in the table.. after searching 

JDBC Questions

execution of java program
have put the classpath as: set path=%path%;C:\Program Files\Java\jdk1.6.0_01...execution of java program  wat are the steps for the execution of the servlet-jdbc program on tomcat 5.5 server.. PlS provide..the execution steps 

Java Beginners

Java Program HELP - Java Beginners
Java Program HELP  Hi I'm having trouble with this problem, I keep getting errors. Write a program GuessGame.java that plays the game ?guess the number? as follows: Your program chooses the number to be guessed by selecting 

Java Beginners

program - Java Beginners
Java vector program  Please give me an example of Java vector program.Thanks!!  hi friendNow, read about vector program. Here, is the used without taking user input.http://www.roseindia.net/java/beginners 

JavaScript Questions

Write a program in java...
Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two... to enter an integer number. Write a program in java to find the factorial 

Java Beginners

program
program  write a program different between to dates in terms of days in java 

Java Beginners

java program for
java program for   java program for printing documents,images and cards 

Programming Tutorials

Match the correct description about purpose and function to which session bean type they apply: stateless, stateful, or both.
Match the correct description about purpose and function to which...;   Match the correct description about purpose and function... of the objects from the instance’s fields reached by following Java object 

Java-Tutorials

Command Line Standard Output In Java
Command Line Standard Output In Java In this section we will discuss about the Command Line Java IO Standard Output. Standard streams, feature of various O... at the console or any other dstination. In this example I have created a Java 

General

Java Example program to get the current working directory
Java Example program to get the current working directory       This example java program illustrates to get the current working directory (CWD). With the File class 

Java Beginners

Java program problem
Java program problem  Hi, I took the chance to login here in your educational page due to my questions in mind about my java programming assignment... is a path to a directory. Example: java DuplicateFinder c:\Documents 

Java-Tutorials

Command Line Standard Error In Java
Command Line Standard Error In Java In this section we will discuss about the Command Line Java IO Standard Error. System.out and System.err both.... In this example I have created a Java class named JavaSystemErrExample.java. 

Java Beginners

program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series 

Java Beginners

compile and run java program
compile and run java program  Hello, everyone!!! I just want to ask if you anyone here knows how to compile java file in linux specifically UBUNTU. For example, I have a java file named Hello.java and saved at my desktop. how 

Advertisements Advertisements
 

 

 

DMCA.com