1. String装换为Java输入流

    InputStream is = new ByteArrayInputStream(text.getBytes("UTF-8"));
  2. List转换为Map

    private Map<String, User> listToMap(List<User> userList) {
        return userList
                .stream()
                .collect(Collectors.toMap(User::getUserName, x -> x));
    }
    
    class User {
        @Getter
        @Setter
        String userName;
        @Getter
        @Setter
        String address;
    }

水一水
39 声望5 粉丝

总结经验,提升自己