Use System.lineSeparator()

Benefit of this way rather than System.getProperty("line.separator") is
that there are no security checks.

Change-Id: I4053e172e09800b3abaf5a189f311eded88cd6db
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java
index 6671a41..3a6f3c0 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/LocalMetaArea.java
@@ -433,7 +433,7 @@
 		path.toFile().getParentFile().mkdirs();
 		IPath tempPath = getBackupLocationFor(path);
 		try {
-			new ModelObjectWriter().write(description, path, tempPath, System.getProperty("line.separator")); //$NON-NLS-1$
+			new ModelObjectWriter().write(description, path, tempPath, System.lineSeparator());
 		} catch (IOException e) {
 			String message = NLS.bind(Messages.resources_writeWorkspaceMeta, path);
 			throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, null, message, e);
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java
index 9931e75..fce5725 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java
@@ -617,7 +617,7 @@
 					table.put(VERSION_KEY, VERSION_VALUE);
 					// print the table to a string and remove the timestamp that Properties#store always adds
 					String s = removeTimestampFromTable(table);
-					String systemLineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
+					String systemLineSeparator = System.lineSeparator();
 					String fileLineSeparator = FileUtil.getLineSeparator(fileInWorkspace);
 					if (!systemLineSeparator.equals(fileLineSeparator))
 						s = s.replaceAll(systemLineSeparator, fileLineSeparator);
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java
index af8dccd..bf506e4 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/FileUtil.java
@@ -318,7 +318,7 @@
 		if (value != null)
 			return value;
 		// if there is no preference set, fall back to OS default value
-		return System.getProperty("line.separator"); //$NON-NLS-1$
+		return System.lineSeparator();
 	}
 
 	/**
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java
index 0df5d36..af94f24 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ModelObjectReaderWriterTest.java
@@ -313,7 +313,7 @@
 	public void testConsistentWrite() throws Throwable {
 		String locationA = getTempDir().append("testPath1").toPortableString();
 		String locationB = getTempDir().append("testPath1").toPortableString();
-		String newline = System.getProperty("line.separator");
+		String newline = System.lineSeparator();
 		String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + newline + "<projectDescription>" + newline + "	<name>MyProjectDescription</name>" + newline + "	<comment></comment>" + newline + "	<projects>" + newline + "	</projects>" + newline + "	<buildSpec>" + newline + "		<buildCommand>" + newline + "			<name>MyCommand</name>" + newline + "			<arguments>" + newline + "				<dictionary>" + newline + "					<key>aA</key>" + newline + "					<value>2 x ARGH!</value>" + newline + "				</dictionary>" + newline + "				<dictionary>" + newline + "					<key>b</key>" + newline + "					<value>ARGH!</value>" + newline + "				</dictionary>" + newline
 				+ "			</arguments>" + newline + "		</buildCommand>" + newline + "	</buildSpec>" + newline + "	<natures>" + newline + "	</natures>" + newline + "	<linkedResources>" + newline + "		<link>" + newline + "			<name>pathA</name>" + newline + "			<type>2</type>" + newline + "			<location>" + locationA + "</location>" + newline + "		</link>" + newline + "		<link>" + newline + "			<name>pathB</name>" + newline + "			<type>2</type>" + newline + "			<location>" + locationB + "</location>" + newline + "		</link>" + newline + "	</linkedResources>" + newline + "</projectDescription>" + newline;
 
@@ -341,7 +341,7 @@
 		description.setLinkDescriptions(linkDescriptions);
 
 		ByteArrayOutputStream buffer = new ByteArrayOutputStream();
-		new ModelObjectWriter().write(description, buffer, System.getProperty("line.separator"));
+		new ModelObjectWriter().write(description, buffer, System.lineSeparator());
 		String result = buffer.toString();
 
 		// order of keys in serialized file should be exactly the same as expected
@@ -627,7 +627,7 @@
 		description.setReferencedProjects(refProjects);
 
 		try (OutputStream output = tempStore.openOutputStream(EFS.NONE, getMonitor())) {
-			writer.write(description, output, System.getProperty("line.separator"));
+			writer.write(description, output, System.lineSeparator());
 		}
 
 		/* test read */
@@ -723,7 +723,7 @@
 		desc.setMaxFileStateSize(123456789l);
 
 		SafeFileOutputStream output = new SafeFileOutputStream(location.toFile());
-		writer.write(desc, output, System.getProperty("line.separator"));
+		writer.write(desc, output, System.lineSeparator());
 		output.close();
 
 		/* test read */
@@ -759,7 +759,7 @@
 		OutputStream output = null;
 		try {
 			output = store.openOutputStream(EFS.NONE, getMonitor());
-			new ModelObjectWriter().write(description, output, System.getProperty("line.separator"));
+			new ModelObjectWriter().write(description, output, System.lineSeparator());
 		} finally {
 			assertClose(output);
 		}
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java
index 8733aee..4c0b22a 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java
@@ -905,7 +905,7 @@
 
 	public void test_384151() throws BackingStoreException, CoreException {
 		// make sure each line separator is different
-		String systemValue = System.getProperty("line.separator");
+		String systemValue = System.lineSeparator();
 		String newInstanceValue;
 		String newProjectValue;
 		if (systemValue.equals("\n")) {
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java
index 302bbec..32771d2 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IProjectTest.java
@@ -699,7 +699,7 @@
 
 	public void testProjectCreationLineSeparator() throws BackingStoreException, CoreException {
 		// make sure each line separator is different
-		String systemValue = System.getProperty("line.separator");
+		String systemValue = System.lineSeparator();
 		String newInstanceValue;
 		String newProjectValue;
 		if (systemValue.equals("\n")) {