?? 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 + -