External JAR and External XML

Put your problem here if it does not fit any of the other categories.

External JAR and External XML

Postby j0shua » Wed Jan 27, 2010 2:32 pm

Hi,

I will try to be as clear as possible. Long time ago I had created I small game in a Standard Java 1.6 project. Now I want to port this application to Android. So what I had tried to do is import my Java Project as a library in my Androd project. But... my Java project use external XML files for config/settings.

So I'm using
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. MyJavaClass.class.getResource("/resources/config.xml");
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
to import my XML file in my Java project to read it. But every time I used this I got and Exception (FileNotFoundException). I know in Android to load XML file you can use:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. getResources().openRawResource(R.raw.config)
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
(this is working). I know that in Android
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. MyAndroidClass.class.getResources(...)
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
is not working (FileNotFoundException).

So I'm asking, how do I open external XML in a non-Android project?

I realy need to get this working, so if i'm not clear in some way, feel free to ask question.

Thanks!
j0shua
Freshman
Freshman
 
Posts: 3
Joined: Sun Jan 24, 2010 4:27 pm

Top

Postby j0shua » Wed Jan 27, 2010 2:38 pm

Something have change... I don't get the FileNotFoundException anymore, now i'm getting this:
Code: Select all
01-27 13:34:01.568: WARN/System.err(218): java.lang.IllegalArgumentException: URI is not hierarchical: jar:file:/data/app/com.test.mytestapp.apk!/resources/config.xml


My code to open the file is:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. File f = new File(ConfigLoader.class.getResource("/resources/config.xml").toURI());
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
j0shua
Freshman
Freshman
 
Posts: 3
Joined: Sun Jan 24, 2010 4:27 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 22 guests