开发者

manually read a file in the files directory

开发者 https://www.devze.com 2023-01-24 14:48 出处:网络
Friends, My application has to get current gps position in every seconds and write this data as byte array to a file in files directory. To check the data in that file I tried to open mnually. B开发者

Friends, My application has to get current gps position in every seconds and write this data as byte array to a file in files directory. To check the data in that file I tried to open mnually. B开发者_JS百科ut i couldn't open. How can i read the file. The file is a text file


private static String readFileAsString(String file) throws IOException {
    byte[] bytes = new byte[(int) new File(file).length()];
    BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file));
    stream.read(bytes);
    return new String(bytes);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消