• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

FileInputStream  RSS feed

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

can anyone please tell me what does the marked lines do ? I mean, what is their functionality respective of the code below.

public static void main(String args[])
{
VRJDBCPropXmlHandler handler = new VRJDBCPropXmlHandler();
try
{
FileInputStream fin = new FileInputStream(args[1]); --------------> ???
handler.execute(fin);
}
catch(FileNotFoundException fnfe)
{
fnfe.printStackTrace();

}
catch(Exception e)
{
e.printStackTrace();
}
}


public void execute(InputStream is) throws Exception {
SAXParser parser = spf_.newSAXParser();
try
{
parser.parse(is, this); ----------------------> ???
}
catch (Exception ex)
{.....
}
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileInputStream fin = new FileInputStream(args[1]); --------------> ???

Usually this line tends to handle the lower layer functionality of reading data from a file in a stream of bytes.
However in your specific case seems that after reading the file you need to parse the contents as xml content with a SAX parser which is what you are attempting here
parser.parse(is, this); ----------------------> ???

While parsing the contents in SAX based parsing you encounter callbacks indicating various situations like begin-of-an-xml tag,end-of-xml-tag along with associated data based on which you can do some meaning ful operation.

Hope this helps.
 
Syed Tabrez
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clarifying my statement
"Usually this line tends to handle the lower layer functionality of reading data from a file in a stream of bytes. "
FileInputStream has functionality to accomplish the reading of the file however in your code snippet you are not invoking any of that explicitly rather the parser I think will invoke it for you.
 
Marshal
Posts: 60136
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use the Code button otherwise your code is so difficult to read.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!