ryanqq / paoding

Automatically exported from code.google.com/p/paoding
0 stars 0 forks source link

PaodingMaker类getFileLastModified方法第242行报错! #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
将paoding-analysis.jar引入项目,初始化Analyzer analyzer = new 
PaodingAnalyzer();时报错。

错误信息输出如下:

error in handler path=file:/F:/workspace/eclipse3.2 workspace/web-search/
lib/lucene-2.2.0/paoding-analysis.jar!/paoding-analysis.properties

error in handler jarPath=/F:/workspace/eclipse3.2 workspace/web-search/lib/
lucene-2.2.0/paoding-analysis.jar!/

Exception in thread "main" 
net.paoding.analysis.exception.PaodingAnalysisException: 
java.io.FileNotFoundException: F:\workspace\eclipse3.2 workspace\web-
search\lib\lucene-2.2.0\paoding-analysis.jar! 
(系统找不到指定的文件。)
    at 
net.paoding.analysis.knife.PaodingMaker.getProperties(PaodingMaker.java:138)
    at 
net.paoding.analysis.analyzer.PaodingAnalyzer.init(PaodingAnalyzer.java:70)
    at 
net.paoding.analysis.analyzer.PaodingAnalyzer.<init>(PaodingAnalyzer.java:59)
    at 
net.paoding.analysis.analyzer.PaodingAnalyzer.<init>(PaodingAnalyzer.java:52)
    at 
com.cdqss.core.searchengine.index.TxtFileIndexer.createIndex(TxtFileIndexer.java
:36)
    at 
com.cdqss.core.searchengine.index.TxtFileIndexer.main(TxtFileIndexer.java:62)
Caused by: java.io.FileNotFoundException: F:\workspace\eclipse3.2 
workspace\web-search\lib\lucene-2.2.0\paoding-analysis.jar! 
(系统找不到指定
的文件。)
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)
    at 
net.paoding.analysis.knife.PaodingMaker.getFileLastModified(PaodingMaker.java:24
2)
    at 
net.paoding.analysis.knife.PaodingMaker.loadProperties(PaodingMaker.java:207)
    at 
net.paoding.analysis.knife.PaodingMaker.getProperties(PaodingMaker.java:129)
    ... 5 more

版本:paoding-analysis-2.0.4-alpha2
环境:WINXP+JDK6.0

经调试追踪到在PaodingMaker类getFileLastModified方法第242行处报错�
��此处代码
为:jarFile = new JarFile(jarPathFile);

Original issue reported on code.google.com by aiwuy...@gmail.com on 11 Dec 2007 at 6:41

GoogleCodeExporter commented 9 years ago
这个是用于路径中包含空格导致的,建议词库路径中不要包��
�空格。

另外,这个bug fix在Svn代码库中。

Original comment by qieqie.wang on 17 Mar 2008 at 3:14

GoogleCodeExporter commented 9 years ago

Original comment by qieqie.wang on 17 Mar 2008 at 3:17

GoogleCodeExporter commented 9 years ago
Two different file path formats for MS Windows and UNIX:

MS Windows - file:/C:/Program Files/xxxx/xxx.jar!xxxx.properties
UNIX: file:/usr/local/xxxx/xxx.jar!xxxx.properties

If you only trim off "file:" protocol, it works for UNIX only:

MS Windows - /C:/Program Files/xxxx/xxx.jar!xxxx.properties <-- Invalid
UNIX: /usr/local/xxxx/xxx.jar!xxxx.properties <-- correct

Please add the following fix:
PaodingMaker.java Line 238:

path = path.replaceAll("%20", " ").replaceAll("\\\\", "/");

jarIndex = path.indexOf(".jar!"); // update jarIndex position
int protocalIndex = path.indexOf(":");

String jarPath = path.substring(protocalIndex + ":".length(), jarIndex 
+ ".jar".length()); // For UNIX - file:/usr/local/xxxx/xxx.jar!xxxx.properties
if (jarPath.indexOf(":") != -1) // For MS Windows - file:/C:/Programe 
Files/xxxx/xxx.jar!xxxx.properties
    jarPath = path.substring(protocalIndex + ":/".length(), jarIndex 
+ ".jar".length());

Original comment by tommych...@gmail.com on 14 Apr 2008 at 8:27