Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Suprith
IO concept
2 Answer(s)      3 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.


Advertisement
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
io
Advertisements
io
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
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
java IO programing
java IO programing  how Java source file is used as input the program will echo lines
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 binary file io example
java binary file io example  java binary file io example
java-io - Java Beginners
java-io  Hi Deepak; down core java io using class in myn code twodimensional arry is not supportin. veryfy my code ... how can i modify this code. Thank you. RameshReddy T
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
Explain normalization concept?
Explain normalization concept?  Explain normalization concept
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 IO Path
Java IO Path In this section we will discuss about the Java IO Path. Storage of a file or folder(Directory/Subdirectory) in a Hard Drive or other media is called a Path of that file or folder using which they can be accessed easily
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
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
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
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 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
Explain the concept of thread priorities in Java.
Explain the concept of thread priorities in Java.  Explain the concept of thread priorities in Java
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
Write Full concept of abstract class
Write Full concept of abstract class  Abstract class
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 & FileOutPutStream vs. 2)InputStreamReader & OutputStreamWriter
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
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
Advertisements
 

 

 

DMCA.com