文档中心 > 淘宝达人

文件存储服务接口

更新时间:2015/09/18 访问次数:71234

文件读写

JAVA代码:

List<String> results = new ArrayList<String>();
StoreService storeService = StoreServiceFactory.getStoreService();
storeService.saveTextFile("写demo真累啊。。。。。不想写了", "/demo/baoyuan.txt");
results.add("保存内容到:/demo/baoyuan.txt ---写demo真累啊。。。。。不想写了---" + storeService.isFileExist("/demo/baoyuan.txt"));
results.add("获取文件内容:/demo/baoyuan.txt ----"
+ storeService.getTextFile("/demo/baoyuan.txt"));
storeService.moveFile("/demo/baoyuan.txt", "/demo/newBaoyuan.txt");
results.add("移动文件:/demo/baoyuan.txt to /demo/newBaoyuan.txt ----"
+ storeService.isFileExist("/demo/newBaoyuan.txt"));
storeService.deleteFile("/demo/newBaoyuan.txt");
results.add("删除文件:/demo/newBaoyuan.txt ----"
+ !storeService.isFileExist("/demo/newBaoyuan.txt"));

执行结果:

保存内容到:/demo/baoyuan.txt ---写demo真累啊。。。。。不想写了---true
获取文件内容:/demo/baoyuan.txt ----写demo真累啊。。。。。不想写了
移动文件:/demo/baoyuan.txt to /demo/newBaoyuan.txt ----true
删除文件:/demo/newBaoyuan.txt ----true

 

FAQ

关于此文档暂时还没有FAQ
返回
顶部