As I found out it is possible to use H2 virtual FS that is much faster then default FS. So, I do this way:
//to save dump
connection.prepareStatement("SCRIPT TO 'memFS:data.sql'").execute();
//to load dump
connection.prepareStatement("RUNSCRIPT FROM 'memFS:data.sql'").execute();