Here you can find the source of writeFile(IFile annotationFile, StringBuffer head, String annotatedSignature, String nextLines, BufferedReader tailReader, IProgressMonitor monitor)
private static void writeFile(IFile annotationFile, StringBuffer head, String annotatedSignature, String nextLines, BufferedReader tailReader, IProgressMonitor monitor) throws CoreException, IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2015, 2016 GK Software AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w w w . j a v a 2s .c om * Stephan Herrmann - initial API and implementation *******************************************************************************/ import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.IOException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; public class Main { /** * Write back the given annotationFile, with the following content: * - head (assumed to include a member and its original signature * - annotatedSignature * - nextLines (optionally, may be null) * - the still unconsumed content of tailReader */ private static void writeFile(IFile annotationFile, StringBuffer head, String annotatedSignature, String nextLines, BufferedReader tailReader, IProgressMonitor monitor) throws CoreException, IOException { head.append(' ').append(annotatedSignature).append('\n'); if (nextLines != null) head.append(nextLines).append('\n'); String line; while ((line = tailReader.readLine()) != null) head.append(line).append('\n'); ByteArrayInputStream newContent = new ByteArrayInputStream(head.toString().getBytes("UTF-8")); //$NON-NLS-1$ annotationFile.setContents(newContent, IResource.KEEP_HISTORY, monitor); } }