IO concept

Ads

 
 

Share on Google+Share on Google+

Suprith
IO concept
2 Answer(s)      6 years and 11 months ago
Posted in : Java Beginners

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

Ads
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....


Ads









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
Artifacts of io
List of Artifacts of io maven depenency
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
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
Write Full concept of abstract class
Write Full concept of abstract class  Abstract class
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
java io - Java Beginners
Java IO Streams  What is the Java IO Stream
io
io
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
IO in java
IO in java  Your search mechanism will take as input a multi-word query and will return a list of documents where the given words appear. 1. Your score for this portion of the assignment will be based on the intelligence of your
io packages - Java Beginners
io packages  How can I add two integers in java using io pacages
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.
java IO programing
java IO programing  how Java source file is used as input the program will echo lines
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
Artifacts of commons-io
List of Artifacts of commons-io maven depenency
Artifacts of excalibur-io
List of Artifacts of excalibur-io maven depenency
java binary file io example
java binary file io example  java binary file io example
Maven Dependency commons-io >> 1.0
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version1.0 in your project
Maven Dependency commons-io >> 1.3
You should include the dependency code given in this page to add Maven Dependency of commons-io >> commons-io version1.3 in your project

Ads

 
Advertisement null

Ads