Home Discussion Discuss: Moving file or directory from one directory to another

  • This can be done with a one-linerAlex Furman July 2, 2011 at 12:19 AM

    Moving a file into another dir is a one-liner. See java.io.File#renameTo Doing what you're doing here, actually copying the content and then deleting the original files is insanity, pure and simple. I would remove this embarassing attempt at a "tutorial" if I were you.

  • renameTopradip garala May 2, 2012 at 4:42 PM

    we can do like this way..... File file = new File("C:\\A\\file.txt"); if(file.renameTo(new File("C:\\B\\" + file.getName()))){ System.out.println("File is moved successful!"); }else{ System.out.println("File is failed to move!"); }

  • Date folder Creationraj August 9, 2012 at 12:59 PM

    Take the file from one folder and move it to new folder which created by Date ? can some one help me.

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
Java-Tutorials

Moving file or directory from one directory to another
Moving file or directory from one directory to another... directory is moved from one directory to another directory. This program... from one directory to another. In this section an example is given 

Java Beginners

File copy from one directory to another in java
File copy from one directory to another in java  I am trying to find very good code example for copying a file from one directory to another...? Is there any size issue while copying the file from one directory to another 

Java Beginners

how to copy file from one directory to another in java with examples
how to copy file from one directory to another in java with examples  how to copy file from one directory to another in java with examples? I want... copy from one directory to another in java. Thanks 

Java-Tutorials

Copy Directory or File in Java
will see how contains of a directory or a file is copied  from... then the program gives the output message like : File or directory does not exist... generates the list of all the sub directories and file inside the source directory 

Java Beginners

How to move a file from a directory to other directory
How to move a file from a directory to other directory  I tried the above example it will move the folder to other directory but it does not move the image file or other file to a specified directory. Can anyone help me? Thanks 

Java Beginners

File Directory Merging
File Directory Merging  Two directories are given. Both contain a large amount of files. Each of the directory can be more than a GB. We need to form a new directory in which all the files from both the directories 

Java Tips and Examples

Java SDK Directory Structure
;    This section introduces the Directory and file structure... directory provides an html file that contains the detail information of SDK shown...: The zip file is a collection of one of more files that has been compressed 

Java Tips and Examples

Java - Copying one file to another
the contents from one specified file to another specified file. copyfile(String... to another specified file from the first one specified file. // For creating a byte... Java - Copying one file to another    

Java Beginners

Adding .txt files in a given directory
files from a given directory and extract tag value from body tag and add each tag value as one .txt file in a given directory? I have extracted tag values but plz help me how can I save each body tag as one .txt file and add in a directory 

Java-Tutorials

Java - Copying one file to another
how to copy contents from one file to another file. This topic is related... called copyfile which copies the contents from one specified file to another... of one file and write to another specified file from the first one specified 

Java Beginners

Create text file at client's directory from server.
Create text file at client's directory from server.  Need java code to create text file at client's directory from server..... Please Help 

Java Beginners

reading multiple files from a directory and writing them into a single file
reading multiple files from a directory and writing them into a single file... this: /*this program reads multiple files * from a single directory. */ package elite.tech.com...{ System.out.println("found only one file..."); System.out.println(files 

Java Beginners

How to load file from the directory in J2ME?
How to load file from the directory in J2ME?  Video player J2ME. I have a folder name "music". I want to display all file with extension is "*.mpg" on the List. How can I do it, plz help me 

RMI Questions

ls: cannot access >: No such file or directory
: cannot access >: No such file or directory error is displayed .No f.txt...ls: cannot access >: No such file or directory  import...(p.getErrorStream())); // read the output from the command while ((s 

Java Beginners

java program to read multiple files from a directory and display them on a jframe
java program to read multiple files from a directory and display them... in a directory and display them one by on on a jframe on jpanel with specific key word contained in the file e.g doctor with next next mode. regards Kenny 

General

Rename the File or Directory in Java
otherwise file or directory will be moved from it's own directory to the default... Rename the File or Directory in Java   ... a file or directory is renamed. This program illustrates you the procedure 

Programming Tutorials

Open Source Directory
(Overview, Articles, Company) Directory Server, which Red Hat acquired from.... At the Joomla Directory we have one objective to provide you with access to a wide range...Open Source Directory Open Source Java Directory The Open Source Java 

Java Beginners

Directory chooser in core java - Java Beginners
[]) { JFrame frame = new JFrame("Directory chooser file example"); FileChooser...Directory chooser in core java  Hi, I have to create a Utility which will copy files from a source folder to the any other folder. For same I want 

Programming Tutorials

EJB directory structure
; beans into one file. This file contain the following files :- 1) XML deployment... EJB directory structure       The tutorial is going to explain the standard directory structure of an EJB 

Java-Tutorials

Traversing a file and directory under a directory
then make an object of File class and pass any directory and filename to its constructor. After that, check it whether the file or directory you have entered is a directory or a file. If it is a directory then it will display 

Java Beginners

Getting Current Directory from java - Java Beginners
Getting Current Directory from java  I'm designing an application in linux where i need to get the current directory of my java file... I'm using.../Softwares/apache-tomcat-5.5.27/logs How to get the directory of my current 

Java Beginners

creating a file in a directory
creating a file in a directory  hi i have tried all the file methods to create a file inside a directory but none of them r working some of them are new File ( ".", "C:/fileInRoot.txt" ) new File ( "myDir", "/otherDir" ) File 

General

URL file Download and Save in the Local Directory
URL file Download and Save in the Local Directory   ... and save this Url File in the specified directory. This program specifies... and FileOutputStream write the data to the local file in a specified directory.  

Java-Tutorials

Java Create Directory Example
(System.in)); String directoryName=br.readLine(); // Create one directory...Java Create Directory Example To create a directory in java call the mkdir..., to many directories in directory you need to call the mkdirs() mehtod. An example 

Java Technology Tutorials

Java count files in a directory
only files in a directory. You have learnt various file operations. Here we are going to find out the number of files from a directory. You can see in the given example, we have created an instance of File class and specify a directory 

PHP Tutorial

PHP list contents of directory
Contents of a directory or a folder can be displayed one by one. readdir() function returns the directory as well as file name. readdir() takes input... Constents of Directory <?php $file=opendir("c:\apache-ant-1.7.1-bin 

EJB Tools

EJB directory structure
; beans into one file. This file contain the following files :- 1) XML deployment... EJB directory structure       The tutorial is going to explain the standard directory structure of an EJB 

General

Display list of files from a directory using Java
Display list of files from a directory using Java In this section, you will learn how to display the list of files of a particular directory or a sub...() method display the list of file names of that directory and if it is having any 

Java Beginners

converting one file format to another
converting one file format to another  Hi ser I need a code to export data from data grid to PDF and XL format plz help me out 

Java-Tutorials

Copy one file into another
;This string is copied from one file to another\n"); bf.close(); InputStream...Copy one file into another In this section, you will learn how to copy content of one file into another file. We will perform this operation by using 

DMCA.com