File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes FileInputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "FileInputStream" Watch "FileInputStream" New topic
Author

FileInputStream

jazy smith
Ranch Hand

Joined: Nov 18, 2009
Posts: 101
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

Joined: Dec 22, 2009
Posts: 9
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

Joined: Dec 22, 2009
Posts: 9
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

Joined: Oct 13, 2005
Posts: 38865
    
  23
Please use the Code button otherwise your code is so difficult to read.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileInputStream