将UTF-8保存的CSV文件中的字符串与arraylist中的字符串进行比较

时间:2018-02-01 13:22:42

标签: java

我有一个CSV文件保存为UTF-8。我在CSV文件中有一个middot,使用System.out打印为问号。我想将它与具有middot的arraylist中的字符串进行比较。 arraylist中的字符串从CSV文件中复制,并使用System.out打印出middot。

由于middot /问号,我无法使用JUnit的assertTrue()来使字符串相等。

    // Reads from the file using this and adds to an ArrayList
ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(fileSource);

ArrayList<Object> inputData = new ArrayList<>();
String line;

try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
    while ((line = reader.readLine()) != null) {
            inputData.add(line);
    }
} catch (IOException e) {
        e.printStackTrace();
}


ArrayList<String> myStrings = new ArrayList<>();

myStrings.add("· Bullet one");
myStrings.add("· Bullet two");
myStrings.add("· Bullet three");

// Comparison uses a for loop
// The inputData is from the CSV file and the expected Data is from the 
myStrings ArrayList
inputData.equals(expectedData)

0 个答案:

没有答案