请解释一下下面的代码
public void open()
{
int returnVal = jfilechooser.showOpenDialog(jf); //jf is JFrame's reference
if(returnVal == JFileChooser.APPROVE_OPTION)
{
//to erase any text in the text area before adding new text
jtextarea.setText(null);
try
{
String fileName = jfilechooser.getSelectedFile().getPath();
String show=jfilechooser.getSelectedFile().getName();
Reader in = new FileReader(jfilechooser.getSelectedFile());
char[] buff = new char[100000];
int nch;
while((nch = in.read(buff, 0, buff.length)) != -1)
jtextarea.append(new String(buff, 0, nch));
String fileContent = jtextarea.getText();
jf.setTitle(show+" : S-Textpad");
}
catch(FileNotFoundException x)
{}
catch(IOException ioe)
{
System.err.println("I/O Error on Open");
}
}
}
public void open()
{
int returnVal = jfilechooser.showOpenDialog(jf); //jf is JFrame's reference
if(returnVal == JFileChooser.APPROVE_OPTION)
{
//to erase any text in the text area before adding new text
jtextarea.setText(null);
try
{
String fileName = jfilechooser.getSelectedFile().getPath();
String show=jfilechooser.getSelectedFile().getName();
Reader in = new FileReader(jfilechooser.getSelectedFile());
char[] buff = new char[100000];
int nch;
while((nch = in.read(buff, 0, buff.length)) != -1)
jtextarea.append(new String(buff, 0, nch));
String fileContent = jtextarea.getText();
jf.setTitle(show+" : S-Textpad");
}
catch(FileNotFoundException x)
{}
catch(IOException ioe)
{
System.err.println("I/O Error on Open");
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它看起来像这样:
但是我不知道代码是否可以编译并且至少有一个无用的行:
It looks like it:
However I don't know if the code compiles and there is at least a useless line: