Eclipse: Set “Text file encoding” by code

This is just set in a preferences value.

The code for this is in org.eclipse.ui.internal.ide.LineDelimiterEditor which uses:

String val = ... line separator ...

Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE)
      .node(project.getName()).node(Platform.PI_RUNTIME);

node.put(Platform.PREF_LINE_SEPARATOR, val);

node.flush();

Note: since this is in an internal class it is not guaranteed to be the same in all releases.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top