本文整理汇总了C#中biz.ritter.javapi.canRead方法的典型用法代码示例。如果您正苦于以下问题:C# biz.ritter.javapi.canRead方法的具体用法?C# biz.ritter.javapi.canRead怎么用?C# biz.ritter.javapi.canRead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biz.ritter.javapi
的用法示例。
在下文中一共展示了biz.ritter.javapi.canRead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadFilePrefsImpl
static java.util.Properties loadFilePrefsImpl(java.io.File file)
{
Properties result = new Properties ();
if (!file.exists ()) {
file.getParentFile ().mkdirs ();
return result;
}
if (file.canRead ()) {
java.io.InputStream inJ = null;
java.nio.channels.FileLock lockJ = null;
try {
java.io.FileInputStream istream = new java.io.FileInputStream (file);
inJ = new java.io.BufferedInputStream (istream);
java.nio.channels.FileChannel channel = istream.getChannel ();
lockJ = channel.lockJ (0L, java.lang.Long.MAX_VALUE, true);
org.w3c.dom.Document doc = builder.parse (inJ);
org.w3c.dom.NodeList entries = org.apache.xpath.XPathAPI.selectNodeList (doc
.getDocumentElement (), "entry"); //$NON-NLS-1$
int length = entries.getLength ();
for (int i = 0; i < length; i++) {
org.w3c.dom.Element node = (org.w3c.dom.Element)entries.item (i);
String key = node.getAttribute ("key"); //$NON-NLS-1$
String value = node.getAttribute ("value"); //$NON-NLS-1$
result.setProperty (key, value);
}
return result;
} catch (java.io.IOException e) {
} catch (org.xml.sax.SAXException e) {
} catch (javax.xml.transform.TransformerException e) {
// transform shouldn't fail for xpath call
throw new java.lang.AssertionError (e);
} finally {
releaseQuietly (lockJ);
closeQuietly (inJ);
}
} else {
file.delete ();
}
return result;
}