The Artima Developer Community
Sponsored Link

Java Answers Forum
Reading Text Files from JAR

5 replies on 1 page. Most recent reply: Oct 23, 2003 11:33 PM by sabab

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Reading Text Files from JAR Posted: Oct 22, 2003 10:55 PM
Reply to this message Reply
Advertisement
Hai

One more doubt regarding JAR,
In my application i am reading a text file and it is working fine.

But when i created a JAR file for this entire application including the text file, the application is not reading from the text file
What can i do on thes? the following is my code

FileReader fr = new FileReader("Favorites.txt");
BufferedReader br = new BufferedReader(fr);

Regards
Sabab


sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Re: Reading Text Files from JAR Posted: Oct 22, 2003 10:59 PM
Reply to this message Reply
One more thing regarding the above. i am using windows native support by calling the followin 'exe', and this thing also not working inside the JAR

Process process;
try{process =Runtime.getRuntime().exec("data/natives.exe");}catch(IOException _IoExc) { }

pls help

Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: Reading Text Files from JAR Posted: Oct 23, 2003 1:36 AM
Reply to this message Reply
> FileReader fr = new FileReader("Favorites.txt");
> BufferedReader br = new BufferedReader(fr);

ClassLoader.getSystemResourceAsStream("Favorites.txt")


This will return you an input stream. Hope this helps.

sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Re: Reading Text Files from JAR Posted: Oct 23, 2003 2:35 AM
Reply to this message Reply
Yes it is working fine....
Thanks .. thanks a lot.. Senthoor K P
by the way is there any answer for this question?

I am using windows native support by calling the following '.exe' file, and this thing also not working inside the JAR

Process process;
try{process =Runtime.getRuntime().exec("data/natives.exe");}catch(IOException _IoExc) { }

pls help

Tim Vernum

Posts: 58
Nickname: tpv
Registered: Dec, 2002

Re: Reading Text Files from JAR Posted: Oct 23, 2003 10:26 PM
Reply to this message Reply
Are you saying the exe is inside the jar?
That's simply not going to work.

When you call Runtime.exec() it lets windows make the call, but windows doesn't know how to execute something inside a jar file.

You'll need to extract the file if you want to do this.

sabab

Posts: 34
Nickname: sabab
Registered: Aug, 2003

Re: Reading Text Files from JAR Posted: Oct 23, 2003 11:33 PM
Reply to this message Reply
Before making JAR it was working, but after making the jar it starts not running..

the code is below

Process process;
try{process =Runtime.getRuntime().exec("data/natives.exe");}catch(IOException _IoExc) { }

is ther any other method without extracting?

Flat View: This topic has 5 replies on 1 page
Topic: Login Previous Topic   Next Topic Topic: JSP & Servlets

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use