NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Read a file using a jar

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
Tyvokka



Joined: 17 Aug 2009
Posts: 2

PostPosted: Tue Aug 18, 2009 1:43 pm    Post subject: Read a file using a jar Reply with quote

I have a program which requires a source txt to gather information from and that is updated weekly. I also need to be able to package the source txt and the jar in a folder. How can I read the source txt using the jar, no matter where it is?
Back to top
Tyvokka



Joined: 17 Aug 2009
Posts: 2

PostPosted: Tue Aug 18, 2009 2:03 pm    Post subject: Reply with quote

I figured it out, from http://stackoverflow.com/questions/320542/how-to-get-the-path-of-a-running-jar-file.
Back to top
Melongo Annabel
Posted via mailing list.





PostPosted: Wed Aug 19, 2009 12:29 am    Post subject: Read a file using a jar Reply with quote

what you should do is to create a class to read and write that file. That class will take two arguments, the file in the jar and the file it's being updated with. For only reading the file, the class will only accept one argument( the file in the jar) but for being updated, the file will accept two arguments ( the file in the jar and the file with the information to update) . If you don't want to do the manual updating on a weekly basis, I would recommend you create a cronjob that will do that for you using your class and the two files as arguments. Thanks.


From: Tyvokka <address-removed>
To: address-removed
Sent: Tuesday, August 18, 2009 8:43:19 AM
Subject: [nbj2ee] Read a file using a jar

I have a program which requires a source txt to gather information from and that is updated weekly. I also need to be able to package the source txt and the jar in a folder. How can I read the source txt using the jar, no matter where it is?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo