扫描程序无法读取文件

时间:2016-04-08 11:31:41

标签: java character-encoding java.util.scanner

我目前正在创建一个工具,可以提取和搜索存储在大学项目的智能手表上的数据。

我已经能够从我的智能手表中提取一个名为“Node.db”的文件,其中包含智能手表所连接的手机的蓝牙MAC地址。我现在正在尝试创建扫描程序而不是扫描此“node.db”文件并打印出MAC地址。

这是我目前的代码:

// Identify the location of the node.txt file    
File file = new File("C:\\WatchData\\node.txt");
// Notify the user that Bluetooth extraction has initalized
Txt_Results.append("Pulling bluetooth data...");
        Scanner in = null;
        try {
            in = new Scanner(file);
            while(in.hasNext())
            {   // Scan till the end of the file
                String line=in.nextLine();
                // Scan the file for this string
                if(line.contains("settings.bluetooth"))
                // Print the MAC Address string out for the user
                    System.out.println(line);
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }      

上一个函数将文件转换为.txt。 代码搜索每一行并查找“settings.bluetooth”,并打印出包含MAC地址的该行(如果找到)。但是,我相信node.db文件的格式是阻止扫描程序找到此字符串。我相信文件中的一些数据是经过编码的。下面显示了如何呈现数据的示例。我相信它是不识别的黑色字符:

Picture of file lines

当我在文件上运行代码时,程序将挂起并且不提供任何错误消息。我让程序运行超过20分钟仍然没有成功。

我尝试从文件中打印的确切行如下所示:

Line showing MAC Address of paired device

我已经在没有这些编码字符的文本文件上测试了此代码,并且可以得出结论代码确实有效。所以我的问题如下:

  

有没有办法可以让扫描仪跳过文件中无法识别的字符,以便继续扫描文件?

提前致谢。

0 个答案:

没有答案
相关问题