Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

JAR executable file read/write on imported file.txt

import

  • Please log in to reply
3 replies to this topic

#1 Serialcek

Serialcek

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 151 posts

Posted 08 March 2012 - 11:39 AM

Hello everyone!

I would like to make an executable JAR file.
The point of the program would be to search a txt file for match and if the word is found print entire line.
I would imported the txt file in the JAR file.

But I would like to add to this my program a function to add new lines to the txt file and if a user restart the program that the new added line would be still there if he search for the word.
Can this and how be done?

Maybe can someone post some links of examples or search words for google ?
  • 0

#2 Norm

Norm

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 397 posts
  • Location:Eastern Florida
  • Programming Language:Java, C++, Assembly

Posted 08 March 2012 - 11:44 AM

I would imported the txt file in the JAR file.

I assume that "import" means to write the txt file into the jar file.
It is not possible to write into a jar file while the java program is executing class files from that jar file.
The txt file would need to be outside of the jar file if it is being updated. It can be read from the jar file, but not updated while it is in the jar file.
  • 0

#3 Serialcek

Serialcek

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 151 posts

Posted 08 March 2012 - 12:36 PM

It means that I would create a new java class in eclipse, add the file.txt in the source folder.
And when I will create the JAR file I will include into it the file.txt from the source folder.
  • 0

#4 Norm

Norm

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 397 posts
  • Location:Eastern Florida
  • Programming Language:Java, C++, Assembly

Posted 08 March 2012 - 12:38 PM

You can put any file in a jar file. You should be able to read any file that is in a jar file from a class in the jar file.
  • 0





Also tagged with one or more of these keywords: import

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download