Tomcat读取文件异常java

时间:2014-06-26 16:33:43

标签: java tomcat io

我正在尝试在TomCat启动时读取文件。不幸的是,它会抛出IO异常,抱怨找不到的文件。

Caused by: java.io.FileNotFoundException: 
`file:\C:\_home\main\IntelliBid\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\intellibid-service\WEB-INF\classes\xxx-privatekey.p12 (The filename, directory name, or volume label syntax is incorrect)`

这是我用来读取文件的代码:

URL filePath = Thread.currentThread().getContextClassLoader().getResource("xxx-privatekey.p12");
final GoogleCredential credential = new GoogleCredential.Builder()
        .setTransport(HTTP_TRANSPORT)
        .setJsonFactory(JSON_FACTORY)
        .setServiceAccountId(serviceAccountId)
        .setServiceAccountScopes(scopes)
        .setServiceAccountPrivateKeyFromP12File(new File(filePath.toString()))
        .build();

我从URI文件路径检查了文件路径实际上是正确的!

你能帮我解决一下当前的问题吗?谢谢你的帮助!

0 个答案:

没有答案