Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)
{.....
}
Posted

This line opens a file for reading as a stream,using args[1] as the path. The variable "args" contain the command line arguments.

FileInputStream fin = new FileInputStream(args[1]);


This line parses the file as XML using the containing class as a DefaultHandler DefaultHandler[^]

parser.parse(is, this); 


Also see: http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/parsers/SAXParser.html#parse(java.io.InputStream,%20org.xml.sax.HandlerBase)[^]
 
Share this answer
 
v3
@rick: hi rick. FileInputStream(args[1]) why is there args[1] parameter ? How can it be used over here? can you please explain in detail ?
 
Share this answer
 
Jazzy, use the "messages" are for additional questions and dialog, as the "answers" section is not threaded. See my original answer for clarification on your question.
 
Share this answer
 
FileInputStream fin = new FileInputStream(args[1]);


The above line opens a file in read mode and the value is retrieved as a stream. args[1] is the filepath. Args[1] is the value given(next to class name) while running the program.

parser.parse(is, this); 




This line parses the file as XML using the containing class as a DefaultHandler DefaultHandler[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900