shoumingfile.java
来自「长沙公交查询管理系统,主要实现对人员资料的管理以及车辆的分配路线。」· Java 代码 · 共 59 行
JAVA
59 行
/*这是负责读说明文件的类*/
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 + =
减小字号Ctrl + -
显示快捷键?