How to duplicate a file in a directory to another directory?

I am a student just has just learn some basic Java programming...May i know how to duplicate a file in a directory to another directory?
How to start in doing this?
Thank You

I was suggesting to use java to send commands to the system shell so to speak....
I don't know of a way to do this... under the File class you can delete files, but there is no provision to copy Files so to speak....
one way would to be to open the file you want to copy with a file reader, and then write it all out to your new file.
see http://java.sun.com/j2se/1.3/docs/api/java/io/FileReader.html for information of FileReaders

Similar Messages

  • How to open my file which is in my c directory

    hi
    how to open my file which is in my c directory
    for example i have one folder called "man" which is in my c directory,
    is there possible to open that folder using sql query,if means please tell me

    hi
    how to open my file which is in my c directory
    for example i have one folder called "man" which is
    s in my c directory,
    is there possible to open that folder using sql
    l query,if means please tell meWell, you can use the UTL_FILE package as described above, within PL/SQL, but if you want to access a file though an SQL query (as you stated) then you'd have to look into creating an external datasource and using SQL syntax such as...
    select whatever
    from table@ext_datasource_name
    What exactly are you trying to achieve?

  • How can automatic save file from apex to user local directory?

    how can save pdf file from apex to user local directory on button click?

    >
    Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your profile with a real handle instead of "940509".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    how can save pdf file from apex to user local directory on button click?As Tony points out the ability to do so would represent a major security breach. The normal approach is to present the user with a download link that when clicked prompts them with a Save dialog in which they can select a location for the downloaded file.
    What is the source of the PDF file?

  • Copy file from directory to another directory

    I need to copy a file from a directory to another directory, but that file is longer than 2M.
    I put the data into a array of bytes and then i passed to a destination directory.
    Now i'm using a BufferedOutputStream but, as i have a file whith 2M, and this dont work.
    How can i resolve this problem.
    Thanks, Luis

    I use This, and it works with all kinds of files. I use it for backups with thousands of files and subdirectories.
    you can use this like "copyFiles("D:\\Source", "D:\\Destination")
    The two directories in the parameter list must exist. Subdirectories will be generated from the method.
    I hope this will help you.
    private void copyFiles(String fromPath, String toPath)
         // copies all files and it�s subdirectories from fromPath to toPath
         // fromPath and toPath must exist
              if (fromPath != null)
                   File dir = new File(fromPath);
                   if (dir.exists() && dir.isDirectory())
                        File [] fileList = dir.listFiles();
                        int count = fileList.length;
                        int i = 0;
                        while (i < count)
                             File f = fileList;
                             i++;
                             if (f.isFile())
                                  String toFile = toPath + File.separator + f.getName();
                                  copyFile(f.getPath(), toFile);
                             else
                                  if (f.isDirectory())
                                       File newPath = new File(toPath + File.separator + f.getName());
                                       newPath.mkdirs();
                                       copyFiles(f.getPath(), newPath.getPath());
                        }// while (i < count
                   }// if (dir.exists() && dir.isDirectory())
              }// if (fromPath != null)
         }// copyFiles(String fromPath, String toPath)
    private void copyFile(String src, String dest)
    // Copies a single File with date and time attributes
              long fileTime;
              try
                   FileChannel in = new FileInputStream(src).getChannel();
                   FileChannel out = new FileOutputStream(dest).getChannel();
                   File inInfo = new File(src);
                   fileTime = inInfo.lastModified();
                   in.transferTo(0, in.size(), out);
                   in.close();
                   out.close();
                   File outInfo = new File(dest);
                   outInfo.setLastModified(fileTime);
              } catch (IOException ioe)
                   System.out.println("An error occured: " + ioe.getMessage());

  • Retreiving the file names from directory inside another directory from application server

    Hi,
    I had a problem in retreiving the file names from a directory inside another directory.
    I tried using the FM's  SUBST_GET_FILE_LIST, RZL_READ_DIR_LOCAL and EPS_GET_DIRECTORY_LISTING
    But here I am getting only one directory details.
    Actually my file is located a directory inside one more directory and one more directory and inside the files are located.
    i.e total 3 directories inside the 3rd one my files are there.
    I need to read the latest file name in the directory.
    So that i can do some manipulation after getting the file name.
    Is there option like OPEN DATASET , READ DATASET and CLOSE DATASET?
    Can anyone please let me know How can i acheive this one.
    Regards
    Ram

    Hi Ram,
        Following thread can be helpful for you, were it shows in the tables structure rsfillst a field RSFILLST-TYPE whether its a directory or file..........
    http://scn.sap.com/thread/865272
    thanks and regards,
    narayan

  • How do I move files from one album to another?

    How can I move files from one album to another? And why does itunes split up imported folders?

    Press the Command key while dragging them.
    (58054)

  • How do I transfer files from one computer to another without using cables??

    How do I transfer files from one computer to another without using cables?

    Wifi network
    Email
    Thumb Drive
    Online storage such as, iCloud Google Docs, SkyDrive, etc.

  • How do you copy files from one user to another

    How do you copy files from one user to another user on the same machine?

    open your home folder in finder move file to public, log into other account, click the go tab on the finder menu, select computer, your hard drive (Macintosh HD Default)>Users, the origonal user> public and drag that file to your specified folder.
    hope it works
    Craig.

  • How to transfer iweb files from one mac to another?

    How to transfer iweb files from one mac to another?
    I have a macbookpro, and I am planing to transfer my iweb data to a new imac, is this possiable and will everything transfer over properly? Will I have problems doing this and how can i do this?

    thank you very much!
    another question,
    if i were to use mobil me to publish my site (at this time i use ftp) will i have the ability to have an outside programer log into my mobil me account and adjust things around in my html codes or add things to my site without iweb? at this time i use ftp and transfer my files from cyberduck to my hosting company. I am new and not very firmilure with the files in my hosting company, so i have help sometimes from a programer that fixes my html codes sometimes for example this page of my site i had someone help me with...
    http://www.sylvartfloraldesigns.com/SylvartFloral_Designs/ScheduleConsultation.html
    will i have the option to do this through mobil me and have someone help me from an outside source, log into my mobil me account and have them adjust things for me?

  • How to recover plist files from a deleted user home directory .dmg file

    Our company is starting to have our mac users authenticate against active Directory, One of the requirement is that the local mac user account short name can not be the same as the active directory account so it is necessary to remove the local users account, we do this by removing the local and turning the home directory into a .dmg file, after the user logs in with their active directory account, we mount the .dmg file and move the files over to the new home directory, However the system does not transfer over the pervious system setting such as Dock settings Desktop background setting, and plist files how do we get these setting moved also.

    there is nothing else to transfer. the problem is probably related to the fact that you are using AD. I'm not familiar with it so can not comment further.

  • How to Move  a file from one Directory to another directory.

    Hi All
    i am having a Java standlone Application reqiurements are
    1---->Connection pool To be Created.
    2---->Using Thread to read Multiple Files Simulatneously.
    3----->After Reading Those file I have to Move it to another folder.
    Plz help me.If possible give me sample code .
    I am in deep trouble for this project.

    Use java.io.File.renameTo(...) (look it up in the API documentation).
    Renaming a file doesn't work if you're trying to move files from one disk to another disk. In that case, you have to copy the file and delete the original.

  • How do i transfer files from one mac to another?

    how do i transfer my files from one mac to another mac?

    I normally use an External Hard Drive or Flash Drive for moving files from both Mac's and PC's, but if you want to move from an old Mac to a new one see > How to use Migration Assistant to transfer files from another Mac

  • How do i transfer files from 1 profile to another

    How do i transfer files from 1 user profile to another

    Choose Go to Folder from the Finder's Go menu, provide /Users/Shared/ as the path, drag them to it, and if desired, from there into the second account's home folder.
    (111041)

  • How to transfer the files from one server to another through pl/sql...?

    I want to transfer all the files from source server with respective directory to designation server with respective directory (designation server - oracle reside server).
    Is it possible to ftp from one server to another server(designation server - oracle reside server) through pl/sql. these two servers are independent & unix server.

    No ... The package mentioned in
    http://www.oracle-base.com/dba/miscellaneous/ftp.pks
    this works for across the server i.e. transfer the files from one server to other (it is basically ftp) ..
    So it is NOT correct that this code transfer the file between two location & with in server..

  • How to copy .gif files from one dir to another using runtime.exec

    hello sir/madem,
    i want to copy some gif and jepg files from one directory to another dir using swing.
    when i tried with using runtime.exec(String[]) i am getting the following error.
    anybody please tell me what is the problem in my program
    java.io.IOException: CreateProcess: ren c:/windows/desktop/copy.java c:/windows/
    cc.java error=0
    code:
    public class copy
         public static void main(String[] args)
              try{
                   String s[]=new String[3];
                        s[0]="ren";
    s[1]="c:/windows/desktop/copy.java";
    s[2]="c:/windows/cc.java";
              Runtime rt=Runtime.getRuntime();
    Process p=rt.exec(s);
              int i=p.waitFor();
              System.out.println("i is "+i);
              }catch(Exception e){System.out.println(e);}
    please mail me to [email protected]
    thanks in advance
    samba reddy
    india

    why use the Runtime? There are methods for this in the IO package ...

Maybe you are looking for

  • Can't get new backup past the starting gate

    After fouling up my first backup since upgrading to Snow Leopard (http://discussions.apple.com/message.jspa?messageID=12245539#12245539), I've reset TM (twice) and reformatted my backup drive (with a single pass of zeroes). But, I cannot get the back

  • I am getting the following error " The following requirements should be met for the RD Session Host Servers in the collection"

    Hello All, I have a windows server 2012 R2 build 9600, I have installed all the required Terminal Services and configured a Session based collection. I have verified that all services are running including the RD Session Host  and I am using an Admin

  • Yahoo calander won't sync with calendar app in Mountain Lion???

    My yahoo calander will not sync to calanders app on my iMac using Mountain Lion. I have 4 email accounts total actually. I have two yahoo, one gmail, and one iCloud account. All of which sync fine on there own when I was running Lion. It's only since

  • Improvements for nokia s40v5 devices

    Hi  I was just thinking... I think this is a good idea for nokia and nokia users... So here's what i mean... all of us have nokia phones right? some of us has nokia phones that runs the nokia s40v5 operating system right?so i was jus thinking...for t

  • Test Messages in SolMan 4.0 (How to)

    We would like to send messages from the testworkbench. For the moment it is also in fuction. But these messages appears in our support monitor. But that is not to be like that. The testers should be able to see only their own messages e.g. over a var