From 32f8422695dd53f92bd5e4e995d7e631b4762d9c Mon Sep 17 00:00:00 2001 From: Thomas Leplus Date: Fri, 17 Sep 2021 21:04:20 -0700 Subject: [PATCH] Fix trimming The trim() method returns a new trimmed string, it does not alter the current string (strings being immutable in Java). --- arduino-core/src/processing/app/BaseNoGui.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index f648d87dae9..11163506038 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -888,8 +888,8 @@ static public void saveFile(String str, File file) throws IOException { // then trim any other character (\r) so saveStrings can print it in the correct // format for every OS String strArray[] = str.split("\n"); - for (String item : strArray) { - item.trim(); + for (int i = 0; i < strArray.length; i++) { + strArray[i] = strArray[i].trim(); } PApplet.saveStrings(temp, strArray);