📄 shoumingfile.java
字号:
/*这是负责读说明文件的类*/
package pro;
import java.io.*;
public class ShouMingFile
{
public ShouMingFile()
{
}
public String wenJian()
{
String str="";
try {
File file = new File("shuoming.txt");
FileInputStream fis = new FileInputStream(file);
byte[] buf = new byte[(int)(file.length())];
fis.read(buf);
str = new String(buf);
// jtxt.setText(str);
fis.close();
}
catch (FileNotFoundException fnfe)
{
System.out.println("文件打开失败。");
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
return str;
}
public String wenJianTianQi()//读天气文件的方法
{
String str="";
try {
File file = new File("tianqi.txt");
FileInputStream fis = new FileInputStream(file);
byte[] buf = new byte[(int)(file.length())];
fis.read(buf);
str = new String(buf);
// jtxt.setText(str);
fis.close();
}
catch (FileNotFoundException fnfe)
{
System.out.println("文件打开失败。");
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -