www.pudn.com > google_examples.zip > MyVirtualFileCreator.java, change:2002-05-05,size:2267b


import net.xmethods.www.*; 
import java.net.URL; 
 
/* 
 
 MyVirtualFileCreator.java 
 
 This is a simple client application that invokes the XMethodsFilesystemService. 
 web service. To use this service, you must first register for a username and 
 password. For more information, see http://www.xmethods.net. 
 
 Sample output: 
 
 E:\test>java MyVirtualFileCreator 
 Writing file TestFile.txt 
 Success 
 Listing files for user kelleher@ramblingrose.com 
 <FileList> 
   <FileDetail> 
     <Name>TestFile.txt</Name> 
     <Type>File</Type> 
     <LastModified ms="1020306308000">May 1, 2002 7:25:08 PM</LastModified> 
     <Bytes>15</Bytes> 
   </FileDetail> 
 <Totals NumberOfEntries="1" TotalBytes="15" FreeBytes="1048561"/> 
 </FileList> 
 Reading file TestFile.txt 
 This is a test. 
 Removing file TestFile.txt 
 Success 
 Listing files 
 <FileList> 
   <Totals NumberOfEntries="0" TotalBytes="0" FreeBytes="1048576"/> 
 </FileList> 
 
*/ 
 
public class MyVirtualFileCreator { 
 
	public static void main(String[] args) { 
 
		try { 
 
			String userid = "your_userid"; 
			String password = "your_password"; 
			String filedata = "This is a test."; 
			String filename = "TestFile.txt"; 
 
			XMethodsFilesystemServiceLocator locator = new XMethodsFilesystemServiceLocator(); 
			URL serviceURL = new URL(locator.getXMethodsFilesystemPortAddress());  
			XMethodsFilesystemBindingStub client = new XMethodsFilesystemBindingStub(serviceURL, null); 
 
			System.out.println("Writing file " + filename); 
			String result = client.writeFile(userid, filedata, filename, password); 
			System.out.println(result); 
 
			System.out.println("Listing files for user " + userid); 
			result = client.listFiles(userid, password); 
			System.out.println(result); 
 
			System.out.println("Reading file " + filename); 
			result = client.readFile(userid, filename, password); 
			System.out.println(result); 
 
			System.out.println("Removing file " + filename); 
			result = client.removeFile(userid, filename, password); 
			System.out.println(result); 
 
			System.out.println("Listing files"); 
			result = client.listFiles(userid, password); 
			System.out.println(result); 
	 
 
		} catch (Exception e) { 
			e.printStackTrace(); 
			System.exit(0); 
		} 
	} 
 
}