Java tutorial
//package com.java2s; /* ****************************************************************************** * * Copyright 2008-2010 Hans Dijkema * * JRichTextEditor is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * JRichTextEditor is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with JRichTextEditor. If not, see <http://www.gnu.org/licenses/>. * * ******************************************************************************/ public class Main { /** * This method inserts the provided string, which should be formatted as XMLNote notes content (paragraphs, etc.) * at the top of the xmlnoteDocument. * * @param xmlnoteDocument An XMLNote XML document. * @param xmlnoteText XMLNote notes content (paragraphs with text and markup). * @return string with the xmlnotetext inserted at the top. */ public static String insertXMLNoteTextAtTheTop(String xmlnoteDocument, String xmlnoteText) { xmlnoteDocument = xmlnoteDocument.replaceAll("[<]notes\\s+[/][>]", "<notes></notes>"); String[] txts = xmlnoteDocument.split("[<]notes[>]", 2); return txts[0] + "<notes>" + xmlnoteText + txts[1]; } }