MCPcopy
hub / github.com/arduino/Arduino / save

Method save

arduino-core/src/processing/app/PreferencesData.java:117–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

115
116
117 static protected void save() {
118 if (!doSave)
119 return;
120
121 if (getBoolean("preferences.readonly"))
122 return;
123
124 // on startup, don't worry about it
125 // this is trying to update the prefs for who is open
126 // before Preferences.init() has been called.
127 if (preferencesFile == null) return;
128
129 // Fix for 0163 to properly use Unicode when writing preferences.txt
130 PrintWriter writer = null;
131 try {
132 writer = PApplet.createWriter(preferencesFile);
133
134 String[] keys = prefs.keySet().toArray(new String[0]);
135 Arrays.sort(keys);
136 for (String key : keys) {
137 if (key.startsWith("runtime."))
138 continue;
139 writer.println(key + "=" + prefs.get(key));
140 }
141
142 writer.flush();
143 } catch (Throwable e) {
144 System.err.println(format(tr("Could not write preferences file: {0}"), e.getMessage()));
145 return;
146 } finally {
147 IOUtils.closeQuietly(writer);
148 }
149
150 try {
151 BaseNoGui.getPlatform().fixPrefsFilePermissions(preferencesFile);
152 } catch (Exception e) {
153 //ignore
154 }
155 }
156
157
158 // .................................................................

Callers 5

initMethod · 0.95
BaseMethod · 0.95
handleOpenMethod · 0.95
handleQuitMethod · 0.95

Calls 10

getBooleanMethod · 0.95
createWriterMethod · 0.95
getPlatformMethod · 0.95
sortMethod · 0.80
trMethod · 0.80
getMethod · 0.65
flushMethod · 0.45
formatMethod · 0.45
getMessageMethod · 0.45

Tested by 2

initMethod · 0.76