如何使用SAE的Storage

时间:2024-05-01 23:07:48

转自:http://blog.****.net/xujainxing/article/details/8981904

Storage在里面当然可以创建文件夹,只不过无法通过代码创建,而是在后台管理页面中的storage来创建的。下面这个例子演示了如何读取Storage中的文件:

注:我的domain叫做mytestapp02,里面有一个叫做hello的文件夹:

  1. <span style="font-size:24px;">  public void storageTest(){
  2. String domain="mytestapp02";
  3. String path="/hello/test.txt";
  4. SaeStorage saeStorage=new SaeStorage();
  5. saeStorage.write(domain, path, "hello,sae!!!!!");
  6. byte[] b=saeStorage.read(domain, path);
  7. System.out.println(new String(b));
  8. }
  9. }</span>

在SAE文档中,第二个参数是filename,其实准确的说应该是文件路径。