public static String getLineDelimiterUsed(IJavaElement elem) throws JavaModelException { ICompilationUnit cu= (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null && cu.exists()) { IBuffer buf= cu.getBuffer(); int length= buf.getLength(); for (int i= 0; i < length; i++) { char ch= buf.getChar(i); if (ch == SWT.CR) { if (i + 1 < length) { if (buf.getChar(i + 1) == SWT.LF) { return "\r\n";
public static String getLineDelimiterUsed(IJavaElement elem) { try { ICompilationUnit cu= (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null && cu.exists()) { IBuffer buf= cu.getBuffer(); int length= buf.getLength(); for (int i= 0; i < length; i++) { char ch= buf.getChar(i); if (ch == SWT.CR) { if (i + 1 < length) { if (buf.getChar(i + 1) == SWT.LF) { return "\r\n"; }
	public static String getLineDelimiterUsed(IJavaElement elem) throws JavaModelException {		ICompilationUnit cu= (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT);		if (cu != null && cu.exists()) {			IBuffer buf= cu.getBuffer();			int length= buf.getLength();			for (int i= 0; i < length; i++) {				char ch= buf.getChar(i);				if (ch == SWT.CR) {					if (i + 1 < length) {						if (buf.getChar(i + 1) == SWT.LF) {							return "\r\n"; //$NON-NLS-1$						}					}					return "\r"; //$NON-NLS-1$				} else if (ch == SWT.LF) {					return "\n"; //$NON-NLS-1$				}			}		}		return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$	}