FileInputStream [英] FileInputStream

查看:99
本文介绍了FileInputStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

谁能告诉我标线的作用?我的意思是,下面的代码分别具有什么功能.

公共静态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)
{.....
}

推荐答案

此行使用args [1]作为路径打开一个文件以流形式读取.变量"args"包含命令行参数.

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]);



此行使用包含的类作为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)[^]


@rick:rick. FileInputStream(args [1])为什么会有args [1]参数?如何在这里使用?您能详细解释一下吗?
@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 ?


爵士乐,请使用消息"来回答其他问题和对话,因为答案"部分没有主题.请参阅我的原始答案以澄清您的问题.
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.


这篇关于FileInputStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆