1. 返回值要返回兩個相互對應的數組,可以用HashMap
HashMap<String, Point> points = new HashMap<String, Point>();
使用的時候通過循環來獲取
for (Entry<String, Point> p : pointsMap.entrySet()) {
System.out.println(p.getKey()); // 打印HashMap裏面的的鍵,就是String
System.out.println(p.getValue()); // 打印HashMap裏面的的值,就是Point
}
2. 判斷文件爲空
import java.io.*;public class test
{
public static void main(String args[]) throws Exception{
FileInputStream fin=new FileInputStream("d:\\empty.txt");
int size=fin.available();
if(size==0){
System.out.println("Empty!");
}else{
System.out.println("Not Empty!");
}
}
}