Java Code for an advanced text editor