Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 撇号符号、欧元符号和英镑符号不完全从远程文本文件获取_Java_Android_Android Emulator_Bufferedreader_Android Fonts - Fatal编程技术网

Java 撇号符号、欧元符号和英镑符号不完全从远程文本文件获取

Java 撇号符号、欧元符号和英镑符号不完全从远程文本文件获取,java,android,android-emulator,bufferedreader,android-fonts,Java,Android,Android Emulator,Bufferedreader,Android Fonts,在我的android应用程序中,我从远程位置获取文本文件的内容。代码如下 URL textUrl; try { textUrl = new URL("http://myurl/data.txt"); BufferedReader bufferReader = new BufferedReader( new InputStreamReader(textUrl.openStream()));

在我的android应用程序中,我从远程位置获取文本文件的内容。代码如下

        URL textUrl;
        try {
        textUrl = new URL("http://myurl/data.txt");
        BufferedReader bufferReader = new BufferedReader(
                new InputStreamReader(textUrl.openStream()));
        String StringBuffer;

        while ((StringBuffer = bufferReader.readLine()) != null) {

            list.add(StringBuffer);

        }
        bufferReader.close();

    } catch (MalformedURLException e) {
    } catch (IOException e) {
    }

    return list;
我的问题是我没有得到确切的数据。文件中的数据是

美国|美国100/50年代| 1.23 | 0|

|美元20/10/5 | 1.23 | 1.259 | 0 | 1.259

|USTC | 0.00 | 0.00 | 0 | 0.00

日元1000 | 1.20 | 1.247 | 0 | 0.00

英镑|英镑1 | 2.08 | 2.116 | 0 | 0.00

欧元|欧元1单位| 1.705 | 1.731 | 0 | 0.00

我得到的数据是

美国|美国100�s/50�s | 1.23 | 0|

|美元20/10/5 | 1.23 | 1.259 | 0 | 1.259

|USTC | 0.00 | 0.00 | 0 | 0.00

日元1000 | 1.20 | 1.247 | 0 | 0.00

英镑|英镑� 1 | 2.08 | 2.116 | 0 | 0.00

欧元� 1个单位| 1.705 | 1.731 | 0 | 0.00

撇号符号、欧元符号和英镑符号替换为� 象征

我在模拟器和设备上都得到了相同的结果

我无法在远程txt文件中执行任何操作

如何获得准确的数据?

我找到了解决方案

1) 找出文件中使用的编码,如@laalto所说。这里的编码是“windows-1252”

2) 然后将代码编辑为

 BufferedReader bufferReader = new BufferedReader(new InputStreamReader(textUrl.openStream(), "windows-1252"));

这对我来说很好。

文本文件的格式应该是Html,UTF-8。欧元符号可以是:&欧元;如何尝试将数据文件保存为UTF-8编码?txt文件应为UTF-8编码。这就是全部。体面的文本编辑器允许你“另存为”。我不能做任何与txt文件。在应用方面我能做些什么吗。找出文件中使用的编码。例如,检查这些非ASCII字符的字节值。2.在代码中读取文件时使用相同的编码。您是如何找到正确的编码的?我的显然不是windows-1252