Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hwo do i read file from local systems D: drive ???

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i read a file from local system's hard drive

InputStream xml_file1 = ClassLoader.getSystemClassLoader().getResourceAsStream("D:\\xml\\mail.xml");

is this correct ???
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the classloader requires a resource be in the classpath. Have a look at java.io.BufferedReader instead.

Your file is XML. You might also look at the javax.xml.parsers package too.
[ February 01, 2007: Message edited by: Paul Sturrock ]
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what if i put mail.xml file in

jboss\server\default\xml_confi\mail.xml ???

will it work ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. Your code is running in an application server. In which case all you need do is put your resource in the classpath and read it in just as you were trying to do originally. However, you neeed to read the JavaDocs to see how you define where the resource is (an absolute path, like the one you have above, will not work).

That being said, what are you trying to do here? Are you trying to configure JBoss's mail service?
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created one method which send mail and one more method which read the e mail address of receiver from mail.xml file.

till now my mail.xml file used to go in .war file so there wasn't any problem of reading xml file but now xml file won't go with .war file.. it will stay out somewhere in jboss directory...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the XML file is in you application's classpath, you should be able to read it fine. See here for a bit of an overview of JBoss's class loader architecture.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic