We can taken the folder as inputstream and move to another ?
i need to move all content in some folder and move to another
we can ?
import java.io.*;
publicclass TestOut{
publicstaticvoid main(String args[]){
try{
File file=new File("c:\\from");
InputStream fis=new FileInputStream(file);
File file2=new File("c:\\to");
OutputStream fos=new FileOutputStream(file2);
while(fis.read()!=-1)fos.write(fis.read());
}catch(Exception e){
e.printStackTrace();
}
}
}
i don't know if any person have idea to move content folder to another
thanks
> thanks for replay
Do you mean 'reply'?
> but when rename the folder already exsit
> will be return flase
If you mean 'false', correct
> this imporve we can't rename
> folder if the name folder already exsit
> you have any idea for that ?
>
> the scenario is i need rename the folder to another
> but when exsit thee folder same the name need to
> renamed will be not rename
> i think this good imagine
I don't understand a word of this.
iam write this program
to rename folder
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ResourceBundle;
/**
* This class represent renaming the file from
* garbage name to arabic name
*
* @author Moayad Fawzi Abu Jaber
* @version 1.0
*
*/
public class RenameFiles{
/**
* Main method to excute the programe will be call
* the file and retrive the rootFile name
* @param arags array of string to enter from comand line
*
*/
public static void main(String args[]){
ResourceBundle recourceBundle=ResourceBundle.getBundle("selectRoot");
String rootName=recourceBundle.getString("root");
File rootFile=new File(rootName);
traceFolder(rootFile);
}
/**
* method will be represent the root folder
* @param roothFile file object created in main method and passed here
*
*/
public static void traceFolder(File rootFile){
File[] files=rootFile.listFiles();
for(int i=0;i<files.length;i++){
if(files[i].isDirectory()){
rename(files[i]);
}
}
}
/**
* here will be rename the folder and recall itself (recarsive)
* @param file will be pass from traceFolder method
*
*/
public static void rename(File file){
String oldName=file.getPath();
byte[] oldBytes=null;
String newName=null;
try{
oldBytes=oldName.getBytes("windows-1252");
newName=new String(oldBytes,"windows-1256");
}catch(UnsupportedEncodingException e){
System.out.println("Error En get Bytes method");
}
file.renameTo(new File(newName));
//here need to speartion the recursive
{
File[] files=file.listFiles();
if(files!=null){
for(int i=0;i<files.length;i++){
if(files[i].isDirectory()){
rename(files[i]);
}
}
}
}//end block of speartion
}
}
now i need now rename some folder ('deleted'==>'trash' ,'outbox'==>'sent')
but some times is found the trash or sent
and need the files in two folder idon't need lose anything