// 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();

...

 

File (Java 2 Platform SE 5_0)

System (Java 2 Platform SE 5_0)

FileInputStream (Java 2 Platform SE 5_0)

String (Java 2 Platform SE 5_0)

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 fabch2 的頭像
    fabch2

    小刻家

    fabch2 發表在 痞客邦 留言(0) 人氣()