1 /*******************************************************************************
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.nls.changes;
13 import java.io.IOException;
14 import java.io.InputStream;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IPath;
18 import org.eclipse.core.runtime.NullProgressMonitor;
20 import org.eclipse.core.resources.IFile;
22 import org.eclipse.jdt.core.IJavaModelStatusConstants;
23 import org.eclipse.jdt.core.JavaModelException;
25 import org.eclipse.jdt.internal.corext.refactoring.nls.NLSUtil;
27 public class CreateTextFileChange extends CreateFileChange {
29 private final String fTextType;
31 public CreateTextFileChange(IPath path, String source, String encoding, String textType) {
32 super(path, source, encoding);
36 public String getTextType() {
40 public String getCurrentContent() throws JavaModelException {
41 IFile file= getOldFile(new NullProgressMonitor());
43 return ""; //$NON-NLS-1$
44 InputStream stream= null;
46 stream= file.getContents();
47 String encoding= file.getCharset();
48 String c= NLSUtil.readString(stream, encoding);
49 return (c == null) ? "": c; //$NON-NLS-1$
50 } catch (CoreException e){
51 throw new JavaModelException(e, IJavaModelStatusConstants.CORE_EXCEPTION);
56 } catch (IOException x) {
61 public String getPreview() {