GoogleApp读文件一法
尽管GoogleApp提供对Java的支持,但是有诸多限制,比如它不允许你写文件。
虽然读文件是允许的,但是要实现文件“读”还是颇费劲的。
折腾了好些光阴,找到了一个很不优雅的解决方法:
首先,准备好你打算读取的文件,假定是一个xml文件,名叫article_info.xml。
然后使用类似如下的方式读写文件:
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse(new File(getClass().getResource("/article_info.xml").getFile()));
最后,在你将应用部署到Google AppServer之前,记得将文件article_info.xm复制到目录war/WEB-INF/classes下面。
标签: Google

0 条评论:
发表评论
<< 主页