Application Deployment : Export .txt or .xml

Hey Monkeys,



i have finished my project. Now i want to export my project to a Desktop Executable.

But the SDK doesn´t export my .txt -files.



I have some .txt-files to print some informations on my Application.



This is my code to load the text:



[java]int my_char = 0;

FileReader reader;

URL res;

File file;

URL res = getClass().getClassLoader().getResource("Interface/Text/start.xml");

File file = new File(res.getFile());

reader = new FileReader(file);

while ((my_char = reader.read()) != -1) {

text_list.add(String.valueOf((char) my_char));

}

[/java]



The text is saved in the Assets/Interface - folder…

I also tried .xml

Its because you use a File in between, use the urls inputstream instead. Its in a jar when deployed, there is no file :slight_smile:

1 Like

i changed it to:



[java]InputStream is = new FileInputStream(“MYPATH/start.txt”);

Reader r = new InputStreamReader(is);



while ((my_char = r.read()) != -1) {

text_list.add(String.valueOf((char) my_char));

} [/java]



this works finde on my PC. But another Pc this doesn´t works because the path has changed. How do i fix it?

How do i have to set “MYPATH” so my jar-File works with text for other PCs?

@normen said:
Its because you use a File in between, use the urls inputstream instead. Its in a jar when deployed, there is no file :)

read again
1 Like

[java]int my_char = 0;

InputStreamReader r;

URL res;

File file;

URL res = getClass().getClassLoader().getResource("Interface/Text/start.xml");

is = res.openStream();

r = new InputStreamReader(is);

while ((my_char = reader.read()) != -1) {

text_list.add(String.valueOf((char) my_char));

}[/java]



That is it!

Yep, but I fixed the r variable in your example code :wink: