Topic: 应用程序中读取的文件路径问题

  Print this page

1.应用程序中读取的文件路径问题 Copy to clipboard
Posted by: qineremma
Posted on: 2004-11-08 13:48

我在应用程序中读取xml文件和声音文件,在客户端运行的话就找不到路径,该怎么读取才能像jb开发时一样能读到呢?

2.Re:应用程序中读取的文件路径问题 [Re: qineremma] Copy to clipboard
Posted by: kavinwang
Posted on: 2004-11-09 17:26

你可以把那些xml文件和声音文件的路径设置到你的classpath中,你再试试。

3.Re:应用程序中读取的文件路径问题 [Re: qineremma] Copy to clipboard
Posted by: qineremma
Posted on: 2004-11-11 09:48

The following code example shows how to retrieve images from a JAR file:

// Get current classloader
ClassLoader cl = this.getClass().getClassLoader();
// Create icons
Icon saveIcon = new ImageIcon(cl.getResource("images/save.gif"));
Icon cutIcon = new ImageIcon(cl.getResource("images/cut.gif"));
...

The example assumes that the following entries exist in one of the JAR files for the application:

images/save.gif
images/cut.gif

ok了。

4.Re:应用程序中读取的文件路径问题 [Re: qineremma] Copy to clipboard
Posted by: xericfish
Posted on: 2004-11-11 15:57

直接都打包到jar文件里面,然后按照楼上的就可以了


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923