/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

import java.util.stream.* ;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String input = "dog🐶" ;
		List < Integer > codePoints = input.codePoints().boxed().collect( Collectors.toList() ); 
		String output = 
		        codePoints
		                .stream()
		                .collect( StringBuilder :: new , StringBuilder :: appendCodePoint , StringBuilder :: append )
		                .toString();
		   
		System.out.println( "input: " + input  ) ;     
		System.out.println( "codePoints: " + codePoints  ) ;          
		System.out.println( "output: " + output  ) ;
		
		String result = Ideone.listOfCodePointsToString( codePoints ) ;
		System.out.println( "result: " + result ) ;
	}
	
	public static final String listOfCodePointsToString( List< Integer > codePoints )
	{
		String output = 
		        codePoints
		                .stream()
		                .filter( codePoint -> Character.isValidCodePoint​( codePoint ) )
		                .collect( StringBuilder :: new , StringBuilder :: appendCodePoint , StringBuilder :: append )
		                .toString();
	    return output ;
	}
}