// get Canonical Path
File file = new File(".");
String path = file.getCanonicalPath();
// set file name
String fileSeparator = System.getProperty("file.separator");
String name = path + fileSeparator + "Server.txt";
// read File
FileInputStream fis = new FileInputStream(name);
byte[] b = new byte[fis.available()];
fis.read(b);
fis.close();
String str = new String(b);
String t1 = str.substring(0, 20).trim();
String t2 = str.substring(20, 40).trim();
String t3 = str.substring(40, 60).trim();
...
System (Java 2 Platform SE 5_0)
全站熱搜