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

FileInputStream

 
jazy smith
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)
{.....
}
 
Syed Tabrez
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • 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