use nio to save data