问题描述
大家好,
谁能告诉我标线的作用?我的意思是,下面的代码分别具有什么功能.
公共静态void main(String args [])
{
VRJDBCPropXmlHandler处理程序=新的VRJDBCPropXmlHandler();
试试
{
FileInputStream fin =新的FileInputStream(args [1]); --------------> ???
handler.execute(fin);
}
catch(FileNotFoundException fnfe)
{
fnfe.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
}
公共无效execute(InputStream is)引发异常{
SAXParser解析器= spf_.newSAXParser();
尝试
{
parser.parse(是这个); ----------------------> ???
}
捕获(异常)
{.....
}
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)
{.....
}
推荐答案
FileInputStream fin = new FileInputStream(args[1]);
此行使用包含的类作为DefaultHandler将文件解析为XML XML [ ^ ]
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)[^]
这篇关于FileInputStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!