`
clearity
  • 浏览: 35623 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Java8下数据列表导出CSV

 
阅读更多
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import org.junit.Test;

public class CSVStreamTest {

    @Test
    public void listToString() {
        List<String> mascots = new ArrayList<>();
        mascots.add("duke");
        mascots.add("juggy");

        String expected = "duke,juggy";
        String actual = mascots.stream().
                reduce((t, u) -> t + "," + u).
                get();
        assertThat(actual, is(expected));
    }
}

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics