【发布时间】:2018-06-27 11:26:19
【问题描述】:
File file = new File( "justskiphere" );
if ( !file.exists() )
{
file =
new File( Thread.currentThread().getContextClassLoader()
.getResource( "general_cat_column_order.xml" ).getFile() );
LOG.info( "Found in the thread" );
}
XMLConfiguration config = null;
try
{
config = new XMLConfiguration( file );
LOG.info( config.getBasePath() );
LOG.info( config.getFileName() );
LOG.info( config.getRootElementName() );
LOG.info( "" + config.getRootNode().getChildren().size() );
}
catch ( final ConfigurationException e )
{
TableColumnHelper.LOG.warn( "Could not find the xml file.", e );
}
你好,
当我尝试从jar 读取时,它确实看到文件在那里,但没有得到它的内容。所以上面LOG的结果是:
12:58:33,665 [main] [INFO] TableColumnHelper - Found in the thread
12:58:33,701 [main] [INFO] TableColumnHelper - /home/mert/Desktop/inspector-1.0-3/file:/home/mert/Desktop/inspector-1.0-3/groundstation.jar!
12:58:33,701 [main] [INFO] TableColumnHelper - general_cat_column_order.xml
12:58:33,701 [main] [INFO] TableColumnHelper - configuration
12:58:33,701 [main] [INFO] TableColumnHelper - 0
12:58:33,702 [main] [INFO] TableColumnHelper - Items in set: 0
我不明白为什么。 jar 是:
general cat column order 是jar 中的文件,里面有内容。
是什么原因?
提前谢谢你。
【问题讨论】:
标签: java xml xml-configuration