• Post Reply Bookmark Topic Watch Topic
  • New Topic

File , read and write

 
Raymond An
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i m not too sure with the Java I/O with files and things . i hope anyone can help i will buy them a pint .
my problem is i need to develop a java program for a module (the lecture is not very nice)- after i develop the porgram i need to turn that to JAR files.
that's how normally develop files to allow to read it and write it.
s = new StaffList("c:\\desm\\data\\Staff.dat");
r = new RoomList("c:\\desm\\data\\Room.dat");
k = new SessionList("c:\\desm\\data\\Session.dat");
m = new ModuleList("c:\\desm\\data\\Module.dat");
just one question not sure when u turn the package to jar files, how can u put those files in to the jar file as well or if i put it into a different machine(LINUX) , how can i know or make sure they can read from the files
in the right path ?
if anyone can help , thanks 100%
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the getResourceAsStream() method of java.lang.class to access any file in the classpath, including files that are contained inside a JAR file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!