1) He has just finished writing
2) He has just finished to write
I guess that you are trying to understand the differences between gerund and infinitive after certain verbs. Unfortunately, after "finish" verb, we just have gerund only.
F.Y.I: we just have some verbs having both forms (gerund and infinitive) with different meaning, not all verbs having that "feature"