Differences between revisions 4 and 5
Revision 4 as of 2006-08-09 15:00:23
Size: 1342
Revision 5 as of 2009-09-20 22:02:42
Size: 1342
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

Creating a new directory and new file

See also CreateDirectoryTreeInJava

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"));


Is there a "Getting Started with the Slide API" guide anywhere? Or a "HelloSlide.java" file that somebody can put up here? I'm looking for some guidance on how to use the Slide API without using WebDAV. Help of any kind is appreciated - URLs, source files, etc. -- JohnMcDonnell

CreateNewDirectoryAndFile (last edited 2009-09-20 22:02:42 by localhost)