AnsweredAssumed Answered

How to create a copy of a file ?

Question asked by darkhope on Apr 18, 2006
Latest reply on May 2, 2006 by rwetherall

Sorry if I made a mistake about the forum where I post my problem, and sorry for my poor english :). :oops:

I want to get some informations about a file or folder, but I don't know how to do.
For my example, I have a file plop.txt in the folder /app:company_home

My function:
public static Reference copyFile(String file1Path, String file2Name, String file2Folder) throws Exception{
        // Get the content service
          ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
          Reference file1Ref = new Reference(STORE, null, file1Path);
           Content[] readResult =
                     new Predicate(new Reference[]{file1Ref}, STORE, null),
           Content content = readResult[0];
          //Create new content in the repository
          createNewContent(file2Name, ContentUtils.getContentAsString(content),file2Folder);
          return content.getNode();

I call my function with this:
copyFile("/app:company_home/plop.txt", "file copy.txt", "/app:company_home");
with the address of the file in first, the name of the new file in second and to finish the path where to create the copy.
So, I would like to search the file "plop.txt" to read it and copy its content into a new file.
But I have a problem with the file1Ref Reference. I would like that it takes informations of the file to open it, but it does not do anything…

Thanks for helping me  :oops: .