Creating a new directory and new file
To create a new file, you need to use the MKCOL to create a new collection.
- boolean success=res.mkcolMethod("/slide/files/testDir");
This will create a new directory called testDir in the files collection. Make sure you include the full path right from the context.
Putting a new file in this directory just requires a PUT. The following putMethod will put a file called newFile.txt in the testDir directory, with content "test data".
- boolean success=res.putMethod("/slide/files/testDir/newFile.txt","test data");
To check whether the contents of the file were really stored, you can retrieve it using:
- String contents={ { { resource.getMethodDataAsString } } }("/slide/files/testDir/newFile.txt");
Getting the file to your local filesystem can be achieved with the following code:
- boolean success=resource.getMethod("/slide/files/testDir/newFile.txt", new java.io.File("C:\\luanne\\newFile.txt"));
-Luanne Coutinho