자바·JSP2020. 4. 20. 00:44
<test>
    <case id='1'>
        <param>100</param>
        <expected>mkyong</expected>
    </case>
    <case id='2'>
        <param>99</param>
        <expected>mkyong</expected>
    </case>
</test>
package com.test;

import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

public class ApplicationTest {

    @DisplayName("Test loading XML")
    @Test
    void loadXMLTest() {

        ClassLoader classLoader = getClass().getClassLoader();

        try (InputStream inputStream = classLoader.getResourceAsStream("xml/data.xml")) {

            String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
            System.out.println(result);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

'자바·JSP' 카테고리의 다른 글

[JAVA] Stream 매칭(allMatch(), anyMatch(), noneMatch())  (0) 2021.03.07
EHCache 설정하기  (0) 2020.05.31
자바 클래스에서 리소스 로드하기  (0) 2020.04.18
XML 파싱 예제  (0) 2020.04.11
[JAVA] OS별로 CPU정보 가져오기  (0) 2019.04.05
Posted by 미랭군