IO concept

IO concept

Write a java program that moves the contents of the one file to another and deletes the old file.

View Answers

December 18, 2010 at 4:44 PM

Hi Friend,

Try the following code:

import java.io.*;
class MoveFile{
    public static void main(String[] args) throws Exception
    {
        File f1=new File("C:/data.txt");
        File f2=new File("D:/data.txt");
        BufferedReader br=new BufferedReader(new FileReader(f1));
        BufferedWriter bw=new BufferedWriter(new FileWriter(f2));

        String line="";
        while((line=br.readLine())!=null){
            bw.write(line);
        }
        bw.close();
        br.close();
        f1.delete();
        System.out.println("File is moved successfully!");
    }
}

For more information, visit the following link:

Java Move File

Thanks


December 19, 2010 at 9:57 PM

Thank U....









Related Tutorials/Questions & Answers:
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 the following code: import java.io.*; class MoveFile{ public static void main(String
Explain normalization concept?
Explain normalization concept?  Explain normalization concept
Advertisements
Concept of subqueires using JSP
Concept of subqueires using JSP  Can I implement the concept of sub queries in JSP page , if yes please tell me how this can be achieved. I have requirement where output of the SQL query should be given as input to the update
session concept - JSP-Servlet
session concept  Hello friends, How can we track unexpectedly closing a window when a jsp project running with session concept. And this tracking should update the log in status in data base
Session concept - JSP-Servlet
Session concept  Hai friends, I am doing a jsp project with session concept. If one person is not accessing his logged window for more than 10 minutes it gets automatically log out.Anybody explain me the reason
FILE HANDLING CONCEPT
FILE HANDLING CONCEPT   Write a program that reads input from the console in the form of a string. When the user enters a word called end, the program should stop reading from the console and print out the values that have been
FILE HANDLING CONCEPT
FILE HANDLING CONCEPT   Write a program that reads input from the console in the form of a string. When the user enters a word called end, the program should stop reading from the console and print out the values that have been
Explain the concept of thread priorities in Java.
Explain the concept of thread priorities in Java.  Explain the concept of thread priorities in Java
Java Inheritance Concept.
Java Inheritance Concept.  Yesterday i got confused with following question in an aptitude exam. Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit
Write Full concept of abstract class
Write Full concept of abstract class  Abstract class
ModuleNotFoundError: No module named 'concept-formation'
ModuleNotFoundError: No module named 'concept-formation'  Hi, My... named 'concept-formation' How to remove the ModuleNotFoundError: No module named 'concept-formation' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'concept-formation'
ModuleNotFoundError: No module named 'concept-formation'  Hi, My... named 'concept-formation' How to remove the ModuleNotFoundError: No module named 'concept-formation' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'concept-formation'
ModuleNotFoundError: No module named 'concept-formation'  Hi, My... named 'concept-formation' How to remove the ModuleNotFoundError: No module named 'concept-formation' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'concept-py'
ModuleNotFoundError: No module named 'concept-py'  Hi, My Python... 'concept-py' How to remove the ModuleNotFoundError: No module named 'concept-py' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'concept-formation'
ModuleNotFoundError: No module named 'concept-formation'  Hi, My... named 'concept-formation' How to remove the ModuleNotFoundError: No module named 'concept-formation' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'concept-py'
ModuleNotFoundError: No module named 'concept-py'  Hi, My Python... 'concept-py' How to remove the ModuleNotFoundError: No module named 'concept-py' error? Thanks   Hi, In your python environment you
Concept error - WebSevices
Concept error  What is the difference between Joomla And Zend framework. Any one know the answer  Hi friend, Joomla CMS is a multi functional Open Source application for creating websites. It is free to use
concept Understatnding problem - Java Beginners
concept Understatnding problem  Even though I have studied in detail inheritance & interfaces in java , I fail to understand "How Interfaces Help in Multiple Inheritance ?" . Pls. Supplement ur ans. with an example. Thanx
Java Query(based on swing concept)
Java Query(based on swing concept)  I want a particular submit button to get disabled whenever i write some account number starting with 774 and 775 in a text box of that screen
Does javaScript have the concept level scope?
Does javaScript have the concept level scope?  Does javaScript have the concept level scope
Java + Timer concept - Java Beginners
concept.  Hi Friend, Try the following code: import java.awt.
Connected Mode and Dissconnect mode coding concept.
Connected Mode and Dissconnect mode coding concept.  Tell Me about Connected Mode and Dissconnect mode coding concept. also give me some syantax
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which implements threading concept. i tried it simply by calling constructor
about the concept - Design concepts & design patterns
about the concept  sir,please explain me how should i interpret the concept "object oriented technology" and how it is differ from "structured langauge".  Object Oriented Language http://www.roseindia.net/java/master
OOPS Concept Abstraction with example - Java Beginners
OOPS Concept Abstraction with example  I am new to java. In java OOPS concept Abstraction means abstract or something. Please explain it with one example  Hi Friend, The process of abstraction in Java is used
Multiarray concept
Thread concept
programming concept
serialization concept
FILE CONCEPT
oop concept
Required help about the concept of JSP page reloading
Required help about the concept of JSP page reloading  Hi, We have one application with Websphere portlet Factory generated JSP as front end, Java in the business layer and finally DB2 as back-end. In certain cases
Required help about the concept of JSP page reloading
Required help about the concept of JSP page reloading  Hi, We have one application with Websphere portlet Factory generated JSP as front end, Java in the business layer and finally DB2 as back-end. In certain cases
how to call a frame having threading concept
how to call a frame having threading concept   i hav a frame having buttton on it .on click event of the button ,i want to call another frame which implements threading concept. i tried it simply by calling constructor
ModuleNotFoundError: No module named 'tool-for-time-tracking-just-proof-of-concept'
-of-concept'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tool-for-time-tracking-just-proof-of-concept...-tracking-just-proof-of-concept' error? Thanks   Hi, In your
wrapper class concept
FILE HANDLING CONCEPT
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT
FILE HANDLING CONCEPT
Version of commons-io>commons-io dependency
List of Version of commons-io>commons-io dependency
Version of excalibur-io>excalibur-io dependency
List of Version of excalibur-io>excalibur-io dependency
Artifacts of io
List of Artifacts of io maven depenency
commons-io
commons-io  Hi, what is commons-io latest dependency? Thanks   Hi, This is the latest version as on today: <dependency> <.../Dependency: commons-io | commons-io Thanks
java io - Java Beginners
Java IO Streams  What is the Java IO Stream
io packages - Java Beginners
io packages  How can I add two integers in java using io pacages
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT
registration form using oop concept

Ads