From c8f90f38bec2981f7f039c911e15c4e015d8250d Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Sun, 15 Sep 2024 11:32:29 +0200 Subject: [PATCH] backport changes from jdt.ui --- .../fix/UseExplicitEncodingFixCore.java | 5 +- .../fix/helper/AbstractExplicitEncoding.java | 12 +- ...ByteArrayOutputStreamExplicitEncoding.java | 13 +- .../ChannelsNewReaderExplicitEncoding.java | 16 +- .../ChannelsNewWriterExplicitEncoding.java | 14 +- .../CharsetForNameExplicitEncoding.java | 11 +- .../helper/FileReaderExplicitEncoding.java | 7 +- .../helper/FileWriterExplicitEncoding.java | 4 +- .../fix/helper/FormatterExplicitEncoding.java | 43 +- .../InputStreamReaderExplicitEncoding.java | 14 +- .../OutputStreamWriterExplicitEncoding.java | 23 +- .../helper/PrintStreamExplicitEncoding.java | 14 +- .../helper/PrintWriterExplicitEncoding.java | 14 +- .../PropertiesStoreToXMLExplicitEncoding.java | 28 +- .../fix/helper/ScannerExplicitEncoding.java | 42 +- .../fix/helper/StringExplicitEncoding.java | 18 +- .../StringGetBytesExplicitEncoding.java | 4 +- .../URLDecoderDecodeExplicitEncoding.java | 45 +- .../URLEncoderEncodeExplicitEncoding.java | 45 +- .../ui/fix/UseExplicitEncodingCleanUp.java | 40 +- .../fix/UseExplicitEncodingCleanUpCore.java | 9 +- .../Java10/ExplicitEncodingCleanUpTest.java | 879 ++++++++++++++++++ 22 files changed, 1145 insertions(+), 155 deletions(-) create mode 100644 sandbox_encoding_quickfix_test/src/org/eclipse/jdt/ui/tests/quickfix/Java10/ExplicitEncodingCleanUpTest.java diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/UseExplicitEncodingFixCore.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/UseExplicitEncodingFixCore.java index 87e48ea3..64a9f4cb 100644 --- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/UseExplicitEncodingFixCore.java +++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/UseExplicitEncodingFixCore.java @@ -16,15 +16,18 @@ import java.util.Set; import org.eclipse.core.runtime.CoreException; + +import org.eclipse.text.edits.TextEditGroup; + import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.rewrite.TargetSourceRangeComputer; + import org.eclipse.jdt.internal.corext.dom.ASTNodes; import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation; import org.eclipse.jdt.internal.corext.fix.LinkedProposalModelCore; import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite; import org.eclipse.jdt.internal.corext.util.Messages; -import org.eclipse.text.edits.TextEditGroup; import org.sandbox.jdt.internal.common.ReferenceHolder; import org.sandbox.jdt.internal.corext.fix.helper.AbstractExplicitEncoding; import org.sandbox.jdt.internal.corext.fix.helper.AbstractExplicitEncoding.ChangeBehavior; diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/AbstractExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/AbstractExplicitEncoding.java index 68fed692..28856824 100644 --- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/AbstractExplicitEncoding.java +++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/AbstractExplicitEncoding.java @@ -21,6 +21,8 @@ import java.util.Map; import java.util.Set; +import org.eclipse.text.edits.TextEditGroup; + import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CompilationUnit; @@ -29,10 +31,10 @@ import org.eclipse.jdt.core.dom.MethodInvocation; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; + import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory; import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation; import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite; -import org.eclipse.text.edits.TextEditGroup; import org.sandbox.jdt.internal.common.ReferenceHolder; import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore; @@ -50,13 +52,13 @@ public abstract class AbstractExplicitEncoding { ); static Set encodings=encodingmap.keySet(); public enum ChangeBehavior {KEEP, USE_UTF8, USE_UTF8_AGGREGATE} - + static class Nodedata { public boolean replace; public ASTNode visited; public String encoding; } - + protected static final String ENCODING = "encoding"; //$NON-NLS-1$ protected static final String REPLACE = "replace"; //$NON-NLS-1$ @@ -111,7 +113,7 @@ protected String computeCharsetforPreview(ChangeBehavior cb) { * * @param cuRewrite CompilationUnitRewrite * @param ast AST - * @param charset + * @param charset * @return FieldAccess that returns Charset for UTF_8 */ protected FieldAccess addCharsetUTF8(CompilationUnitRewrite cuRewrite, AST ast, String charset) { @@ -125,7 +127,7 @@ protected FieldAccess addCharsetUTF8(CompilationUnitRewrite cuRewrite, AST ast, */ FieldAccess fieldaccess= ast.newFieldAccess(); fieldaccess.setExpression(ASTNodeFactory.newName(ast, StandardCharsets.class.getSimpleName())); - + fieldaccess.setName(ast.newSimpleName(charset)); return fieldaccess; } diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ByteArrayOutputStreamExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ByteArrayOutputStreamExplicitEncoding.java index b9188182..c5a4114d 100644 --- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ByteArrayOutputStreamExplicitEncoding.java +++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ByteArrayOutputStreamExplicitEncoding.java @@ -19,6 +19,9 @@ import java.util.List; import java.util.Set; +import org.eclipse.text.edits.TextEditGroup; +import org.sandbox.jdt.internal.common.HelperVisitor; +import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CompilationUnit; @@ -26,14 +29,12 @@ import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; import org.eclipse.jdt.core.dom.rewrite.ListRewrite; + +import org.sandbox.jdt.internal.common.ReferenceHolder; import org.eclipse.jdt.internal.corext.dom.ASTNodes; import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation; import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; -import org.eclipse.text.edits.TextEditGroup; -import org.sandbox.jdt.internal.common.HelperVisitor; -import org.sandbox.jdt.internal.common.ReferenceHolder; -import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore; /** @@ -49,7 +50,7 @@ * } catch (UnsupportedEncodingException e1) { * e1.printStackTrace(); * } - * + * * since Java 10 *
ByteArrayOutputStream ba=new ByteArrayOutputStream();
  *         String result=ba.toString(Charset.defaultCharset());
@@ -82,7 +83,6 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
 			nd.visited=argstring3;
 			holder.put(visited,nd);
 			operations.add(fixcore.rewrite(visited, cb, holder));
-			nodesprocessed.add(visited);
 			return false;
 		}
 		if (ASTNodes.usesGivenSignature(visited, ByteArrayOutputStream.class.getCanonicalName(), METHOD_TOSTRING)) {
@@ -92,7 +92,6 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
 			nd2.visited=visited;
 			holder.put(visited,nd2);
 			operations.add(fixcore.rewrite(visited, cb, holder));
-			nodesprocessed.add(visited);
 			return false;
 		}
 		return false;
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewReaderExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewReaderExplicitEncoding.java
index ccb9ac10..64329d33 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewReaderExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewReaderExplicitEncoding.java
@@ -19,6 +19,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -26,21 +28,21 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
+import org.sandbox.jdt.internal.common.HelperVisitor;
+import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
-import org.sandbox.jdt.internal.common.HelperVisitor;
-import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
  * Java 10
- * 
+ *
  * Change
  *
  * Find:     Reader r=Channels.newReader(ch,"UTF-8")
- * 
+ *
  * Rewrite:  Reader r=Channels.newReader(ch,StandardCharsets.UTF_8)
  *
  */
@@ -98,10 +100,10 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 	@Override
 	public String getPreview(boolean afterRefactoring,ChangeBehavior cb) {
 		if(afterRefactoring) {
-			return "Reader r=\"Channels.newReader(ch,StandardCharsets.UTF_8)\";\n"+ //$NON-NLS-1$
+			return "Reader r=Channels.newReader(ch,StandardCharsets.UTF_8);\n"+ //$NON-NLS-1$
 					""; //$NON-NLS-1$
 		}
-		return "Reader r=\"Channels.newReader(ch,\"UTF-8\")\";\n"+ //$NON-NLS-1$
+		return "Reader r=Channels.newReader(ch,\"UTF-8\");\n"+ //$NON-NLS-1$
 		""; //$NON-NLS-1$
 	}
 }
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewWriterExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewWriterExplicitEncoding.java
index 2ded2bfd..56e1603a 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewWriterExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ChannelsNewWriterExplicitEncoding.java
@@ -20,6 +20,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -27,17 +29,17 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
+import org.sandbox.jdt.internal.common.HelperVisitor;
+import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
-import org.sandbox.jdt.internal.common.HelperVisitor;
-import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
  * Java 10
- * 
+ *
  * Find:  Channels.newWriter(ch,"UTF-8")
  *
  * Rewrite: Channels.newWriter(ch,StandardCharsets.UTF_8)
@@ -97,10 +99,10 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 	@Override
 	public String getPreview(boolean afterRefactoring,ChangeBehavior cb) {
 		if(afterRefactoring) {
-			return "Writer w=\"Channels.newWriter(ch, StandardCharsets.UTF_8)\";\n"+ //$NON-NLS-1$
+			return "Writer w=Channels.newWriter(ch, StandardCharsets.UTF_8);\n"+ //$NON-NLS-1$
 					""; //$NON-NLS-1$
 		}
-		return "Writer w=\"Channels.newWriter(ch, \"UTF-8\")\";\n"+ //$NON-NLS-1$
+		return "Writer w=Channels.newWriter(ch, \"UTF-8\");\n"+ //$NON-NLS-1$
 		""; //$NON-NLS-1$
 	}
 }
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/CharsetForNameExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/CharsetForNameExplicitEncoding.java
index ed047f41..1fe98193 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/CharsetForNameExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/CharsetForNameExplicitEncoding.java
@@ -19,23 +19,26 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.MethodInvocation;
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+
+
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
  * Java 18
- * 
+ *
  * Find:  Charset.forName("UTF-8")
  *
  * Rewrite: StandardCharsets.UTF_8
@@ -92,10 +95,10 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 	@Override
 	public String getPreview(boolean afterRefactoring,ChangeBehavior cb) {
 		if(afterRefactoring) {
-			return "Charset s=\"StandardCharsets.UTF_8\";\n"+ //$NON-NLS-1$
+			return "Charset s=StandardCharsets.UTF_8;\n"+ //$NON-NLS-1$
 					""; //$NON-NLS-1$
 		}
-		return "Charset s=\"Charset.forName(\"UTF-8\")\";\n"+ //$NON-NLS-1$
+		return "Charset s=Charset.forName(\"UTF-8\");\n"+ //$NON-NLS-1$
 		""; //$NON-NLS-1$
 	}
 }
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileReaderExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileReaderExplicitEncoding.java
index dc900e06..9bc6d313 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileReaderExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileReaderExplicitEncoding.java
@@ -19,17 +19,20 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+
+
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
@@ -37,7 +40,7 @@
  * Change
  *
  * Find:  	Reader is=new FileReader("file.txt")
- * 
+ *
  * Rewrite: Reader is=new InputStreamReader(new FileInputStream("file.txt"),Charset.defaultCharset());
  *
  * Charset.defaultCharset() is available since Java 1.5
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileWriterExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileWriterExplicitEncoding.java
index 4c37cb29..25d1994f 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileWriterExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FileWriterExplicitEncoding.java
@@ -18,16 +18,18 @@
 import java.io.OutputStreamWriter;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FormatterExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FormatterExplicitEncoding.java
index 4fac6aaf..51279c19 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FormatterExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/FormatterExplicitEncoding.java
@@ -17,6 +17,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -24,39 +26,45 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
- * 
+ *
  * Find: 		new java.util.Formatter(new File(), String cs)
- * 
+ * throws UnsupportedEncodingException
+ *
  * Rewrite: 	new java.util.Formatter(new File(), Charset cs)
- * 
+ *
  * Find: 		new java.util.Formatter(new File(), String cs,new java.util.Locale())
- * 
+ *
  * Rewrite: 	new java.util.Formatter(new File(), Charset cs,new java.util.Locale())
- * 
+ *
  * Find: 		new java.util.Formatter(new java.io.OutputStream(), String cs)
- * 
+ *
  * Rewrite: 	new java.util.Formatter(new java.io.OutputStream(), Charset cs)
- * 
+ *
  * Find: 		new java.util.Formatter(new java.io.OutputStream(), String cs,new java.util.Locale())
- * 
+ *
  * Rewrite: 	new java.util.Formatter(new java.io.OutputStream(), Charset cs,new java.util.Locale())
- * 
+ *
  * Find: 		new java.util.Formatter(new String(), String cs)
- * 
+ *
  * Rewrite: 	new java.util.Formatter(new String(), Charset cs)
- * 
+ *
  * Find: 		new java.util.Formatter(new String(), String cs,new java.util.Locale())
- * 
+ *
  * Rewrite: 	new java.util.Formatter(new String(), Charset cs,new java.util.Locale())
  *
+ * Find: 		new java.util.Formatter(new File())
+ *
+ * Rewrite: 	new java.util.Formatter(new File(), Charset.defaultCharset())
+ * depends on https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/lang/System.html#file.encoding
+ *
  */
 public class FormatterExplicitEncoding extends AbstractExplicitEncoding {
 
@@ -85,6 +93,7 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			nd.replace=true;
 			nd.visited=argstring3;
 			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		case 1:
 			Nodedata nd2=new Nodedata();
@@ -92,11 +101,11 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			nd2.replace=false;
 			nd2.visited=visited;
 			holder.put(visited,nd2);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		default:
 			break;
 		}
-		operations.add(fixcore.rewrite(visited, cb, holder));
 		return false;
 	}
 
@@ -116,7 +125,7 @@ public void rewrite(UseExplicitEncodingFixCore upp,final ClassInstanceCreation v
 		 * Add Charset.defaultCharset() as second (last) parameter
 		 */
 		ListRewrite listRewrite= rewrite.getListRewrite(visited, ClassInstanceCreation.ARGUMENTS_PROPERTY);
-		if(((Nodedata)(data.get(visited))).encoding!= null) {
+		if(((Nodedata)(data.get(visited))).replace) {
 			listRewrite.replace(((Nodedata) data.get(visited)).visited, callToCharsetDefaultCharset, group);
 		} else {
 			listRewrite.insertLast(callToCharsetDefaultCharset, group);
@@ -126,8 +135,8 @@ public void rewrite(UseExplicitEncodingFixCore upp,final ClassInstanceCreation v
 	@Override
 	public String getPreview(boolean afterRefactoring,ChangeBehavior cb) {
 		if(afterRefactoring) {
-			return "Reader r=new java.util.Formatter(in, "+computeCharsetforPreview(cb)+");\nInputStreamReader is=new InputStreamReader(new FileInputStream(\"\"), \"UTF-8\");\n"; //$NON-NLS-1$ //$NON-NLS-2$
+			return "Formatter r=new java.util.Formatter(out, "+computeCharsetforPreview(cb)+");\n"; //$NON-NLS-1$ //$NON-NLS-2$
 		}
-		return "Reader r=new java.util.Formatter(in);\nInputStreamReader is=new InputStreamReader(new FileInputStream(\"\"), StandardCharsets.UTF_8);\n"; //$NON-NLS-1$
+		return "Formatter r=new java.util.Formatter(out);\n"; //$NON-NLS-1$
 	}
 }
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/InputStreamReaderExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/InputStreamReaderExplicitEncoding.java
index 39d93fb8..040bd1c4 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/InputStreamReaderExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/InputStreamReaderExplicitEncoding.java
@@ -17,6 +17,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -24,19 +26,19 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
- * 
+ *
  * Find: 		InputStreamReader(InputStream in, String cs)
- * 
+ *
  * Rewrite: 	InputStreamReader(InputStream in, Charset cs) is available since Java 1.4
- * 
+ *
  * Charset.defaultCharset() is available since Java 1.5
  *
  */
@@ -66,6 +68,7 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			nd.replace=true;
 			nd.visited=argstring3;
 			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		case 1:
 			Nodedata nd2=new Nodedata();
@@ -73,11 +76,12 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			nd2.replace=false;
 			nd2.visited=visited;
 			holder.put(visited,nd2);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		default:
 			break;
 		}
-		operations.add(fixcore.rewrite(visited, cb, holder));
+
 		return false;
 	}
 
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/OutputStreamWriterExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/OutputStreamWriterExplicitEncoding.java
index 886f02cc..9767881a 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/OutputStreamWriterExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/OutputStreamWriterExplicitEncoding.java
@@ -14,10 +14,11 @@
 package org.sandbox.jdt.internal.corext.fix.helper;
 
 import java.io.OutputStreamWriter;
-
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -25,10 +26,10 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
@@ -37,24 +38,24 @@
  * Change
  *
  * Find:  	OutputStreamWriter os=new OutputStreamWriter(InputStream in, String cs)
- * 
+ *
  * Rewrite:	OutputStreamWriter os=new OutputStreamWriter(InputStream in, CharSet cs)
- * 
- * 
+ *
+ *
  * Find:  	OutputStreamWriter os=new OutputStreamWriter(InputStream in)
- * 
+ *
  * Rewrite:	OutputStreamWriter os=new OutputStreamWriter(InputStream in, Charset.defaultCharset())
  *
  *
  * Find:  	OutputStreamWriter os=new OutputStreamWriter(InputStream in)
- * 
+ *
  * Rewrite:	OutputStreamWriter os=new OutputStreamWriter(InputStream in, StandardCharsets.UTF_8)
- * 
+ *
  * Charset.defaultCharset() is available since Java 1.5
  *
  */
 public class OutputStreamWriterExplicitEncoding extends AbstractExplicitEncoding {
-	
+
 	@Override
 	public void find(UseExplicitEncodingFixCore fixcore, CompilationUnit compilationUnit, Set operations, Set nodesprocessed,ChangeBehavior cb) {
 		ReferenceHolder datah= new ReferenceHolder<>();
@@ -79,6 +80,7 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			nd.replace=true;
 			nd.visited=argstring3;
 			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		case 1:
 			Nodedata nd2=new Nodedata();
@@ -86,11 +88,12 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			nd2.replace=false;
 			nd2.visited=visited;
 			holder.put(visited,nd2);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		default:
 			break;
 		}
-		operations.add(fixcore.rewrite(visited, cb, holder));
+
 		return false;
 	}
 
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintStreamExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintStreamExplicitEncoding.java
index d0261870..717dbae1 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintStreamExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintStreamExplicitEncoding.java
@@ -20,17 +20,19 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
@@ -38,15 +40,15 @@
  * Change
  *
  * Find:     Stream fw=new PrintStream("file.txt", "UTF-8")
- * 
+ *
  * Rewrite:  Stream fw=new PrintStream("file.txt", StandardCharsets.UTF_8)
- * 
+ *
  * Find:     Stream fw=new PrintStream(new File("file.txt"), "UTF-8")
- * 
+ *
  * Rewrite:  Stream fw=new PrintStream(new File("file.txt"), StandardCharsets.UTF_8)
- * 
+ *
  * Find:     Stream fw=new PrintStream(new java.io.OutputStream(), boolean, "UTF-8")
- * 
+ *
  * Rewrite:  Stream fw=new PrintStream(new java.io.OutputStream(), boolean, StandardCharsets.UTF_8)
  *
  */
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintWriterExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintWriterExplicitEncoding.java
index d3763474..4fcb51f9 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintWriterExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PrintWriterExplicitEncoding.java
@@ -19,31 +19,33 @@
 import java.io.PrintWriter;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
 import org.eclipse.jdt.core.dom.CompilationUnit;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
+
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
- * 
+ *
  * Java 10
- * 
+ *
  * Change
  *
  * Find:     	Writer fw=new PrintWriter("file.txt")
- * 
+ *
  * Rewrite:    	Writer fw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("file.txt"),defaultCharset)));
- * 
+ *
  * Find:     	Writer fw=new PrintWriter(new File("file.txt"))
- * 
+ *
  * Rewrite:    	Writer fw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("file.txt"),defaultCharset)));
  *
  * Charset.defaultCharset() is available since Java 1.5
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PropertiesStoreToXMLExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PropertiesStoreToXMLExplicitEncoding.java
index a52a879d..005eeca2 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PropertiesStoreToXMLExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/PropertiesStoreToXMLExplicitEncoding.java
@@ -19,6 +19,8 @@
 import java.util.Properties;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -26,17 +28,21 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
- * Find:  Properties.storeToXML(java.io.OutputStream,String,"UTF-8")
+ * Find:  Properties.storeToXML(java.io.OutputStream,"comment","UTF-8")
+ * throws UnsupportedEncodingException
+ * By default the UTF-8 character encoding is used
+ * so Properties.storeToXML(java.io.OutputStream,"comment")
+ * is the same as Properties.storeToXML(java.io.OutputStream,"comment", StandardCharsets.UTF_8)
  *
- * Rewrite: Properties.storeToXML(java.io.OutputStream,StandardCharsets.UTF_8)
+ * Rewrite: Properties.storeToXML(java.io.OutputStream,"comment", StandardCharsets.UTF_8)
  *
  */
 public class PropertiesStoreToXMLExplicitEncoding extends AbstractExplicitEncoding {
@@ -65,18 +71,20 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			nd.replace=true;
 			nd.visited=argstring3;
 			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
-		case 0:
+		case 2:
 			Nodedata nd2=new Nodedata();
-			nd2.encoding=null;
+			nd2.encoding="UTF_8"; //$NON-NLS-1$
 			nd2.replace=false;
 			nd2.visited=visited;
 			holder.put(visited,nd2);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		default:
 			return false;
 		}
-		operations.add(fixcore.rewrite(visited, cb, holder));
+
 		return false;
 	}
 
@@ -92,10 +100,10 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 		}
 		ASTNode callToCharsetDefaultCharset= computeCharsetASTNode(cuRewrite, ast, cb, ((Nodedata) data.get(visited)).encoding);
 		/**
-		 * Add Charset.defaultCharset() as second (last) parameter
+		 * Add StandardCharsets.UTF_8 as third (last) parameter
 		 */
 		ListRewrite listRewrite= rewrite.getListRewrite(visited, MethodInvocation.ARGUMENTS_PROPERTY);
-		if(((Nodedata)(data.get(visited))).encoding!= null) {
+		if(((Nodedata)(data.get(visited))).replace) {
 			listRewrite.replace(((Nodedata) data.get(visited)).visited, callToCharsetDefaultCharset, group);
 		} else {
 			listRewrite.insertLast(callToCharsetDefaultCharset, group);
@@ -105,10 +113,10 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 	@Override
 	public String getPreview(boolean afterRefactoring,ChangeBehavior cb) {
 		if(afterRefactoring) {
-			return "Properties p=\"new Properties()\";\n"+ //$NON-NLS-1$
+			return "Properties p=new Properties();\n"+ //$NON-NLS-1$
 					"p.storeToXML(java.io.OutputStream,String,"+computeCharsetforPreview(cb)+");\n"; //$NON-NLS-1$ //$NON-NLS-2$
 		}
-		return "Properties p=\"new Properties()\";\n"+ //$NON-NLS-1$
+		return "Properties p=new Properties();\n"+ //$NON-NLS-1$
 		"p.storeToXML(java.io.OutputStream,String,\"UTF-8\");\n"; //$NON-NLS-1$
 	}
 }
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ScannerExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ScannerExplicitEncoding.java
index 940ab14c..d82c7a9a 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ScannerExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/ScannerExplicitEncoding.java
@@ -17,6 +17,8 @@
 import java.util.Scanner;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -24,31 +26,34 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
- * 
+ *
  * Java 10
- * 
+ *
  * Change
  *
- * Find:     	new java.util.Scanner(new File("asdf"),"UTF-8")
- * 
- * Rewrite:    	new java.util.Scanner(new File("asdf"),StandardCharsets.UTF_8);
- * 
- * Find:     	new java.util.Scanner("asdf", "UTF-8")
- * 
- * Rewrite:    	new java.util.Scanner("asdf", StandardCharsets.UTF_8)
- * 
+ * Find:     	new java.util.Scanner(new File("filename.txt"),"UTF-8")
+ *
+ * Rewrite:    	new java.util.Scanner(new File("filename.txt"),StandardCharsets.UTF_8);
+ *
+ * Find:     	new java.util.Scanner("filename.txt", "UTF-8")
+ *
+ * Rewrite:    	new java.util.Scanner("filename.txt", StandardCharsets.UTF_8)
+ *
  * Find:     	new java.util.Scanner(java.io.OutputStream, "UTF-8")
- * 
+ *
  * Rewrite:    	new java.util.Scanner(java.io.OutputStream, StandardCharsets.UTF_8)
  *
+ * Find:     	new java.util.Scanner(java.io.OutputStream)
+ *
+ * Rewrite:    	new java.util.Scanner(java.io.OutputStream, Charset.defaultCharset())
  */
 public class ScannerExplicitEncoding extends AbstractExplicitEncoding {
 
@@ -76,6 +81,7 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
 			nd.replace=true;
 			nd.visited=argstring4;
 			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		case 2:
 			if(!(arguments.get(1) instanceof StringLiteral)) {
@@ -90,12 +96,20 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
 			nd2.replace=true;
 			nd2.visited=argstring3;
 			holder.put(visited,nd2);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		case 1:
+			Nodedata nd3=new Nodedata();
+			nd3.encoding=null;
+			nd3.replace=false;
+			nd3.visited=visited;
+			holder.put(visited,nd3);
+			operations.add(fixcore.rewrite(visited, cb, holder));
+			break;
 		default:
 			break;
 		}
-		operations.add(fixcore.rewrite(visited, cb, holder));
+
 		return false;
 	}
 
@@ -115,7 +129,7 @@ public void rewrite(UseExplicitEncodingFixCore upp,final ClassInstanceCreation v
 		 * Add Charset.defaultCharset() as second (last) parameter
 		 */
 		ListRewrite listRewrite= rewrite.getListRewrite(visited, ClassInstanceCreation.ARGUMENTS_PROPERTY);
-		if(((Nodedata)(data.get(visited))).encoding!= null) {
+		if(((Nodedata)(data.get(visited))).replace) {
 			listRewrite.replace(((Nodedata) data.get(visited)).visited, callToCharsetDefaultCharset, group);
 		} else {
 			listRewrite.insertLast(callToCharsetDefaultCharset, group);
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringExplicitEncoding.java
index ac6fa428..119421e7 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringExplicitEncoding.java
@@ -16,6 +16,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ClassInstanceCreation;
@@ -23,25 +25,25 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
- * 
+ *
  * Java 10
- * 
+ *
  * Change
  *
  * Find:     	String s=new String(byte[],"UTF-8")
- * 
+ *
  * Rewrite:    	String s=new String(byte[],StandardCharsets.UTF_8);
- * 
+ *
  * Find:     	String s=new String(byte[],int, int, "UTF-8")
- * 
+ *
  * Rewrite:    	String s=new String(byte[],int, int, StandardCharsets.UTF_8)
  *
  */
@@ -71,6 +73,7 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
 			nd.replace=true;
 			nd.visited=argstring4;
 			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		case 2:
 			if(!(arguments.get(1) instanceof StringLiteral)) {
@@ -85,12 +88,13 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore, Set<
 			nd2.replace=true;
 			nd2.visited=argstring3;
 			holder.put(visited,nd2);
+			operations.add(fixcore.rewrite(visited, cb, holder));
 			break;
 		case 1:
 		default:
 			break;
 		}
-		operations.add(fixcore.rewrite(visited, cb, holder));
+
 		return false;
 	}
 
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringGetBytesExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringGetBytesExplicitEncoding.java
index 01075084..d443dd7b 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringGetBytesExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/StringGetBytesExplicitEncoding.java
@@ -18,6 +18,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -25,10 +27,10 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLDecoderDecodeExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLDecoderDecodeExplicitEncoding.java
index bb1e44ed..575258fa 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLDecoderDecodeExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLDecoderDecodeExplicitEncoding.java
@@ -19,6 +19,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -26,21 +28,36 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
  * Java 10
- * 
+ *
  * Find:  java.net.URLDecoder.decode("asdf","UTF-8")
  *
  * Rewrite: java.net.URLDecoder.decode("asdf",StandardCharsets.UTF_8)
  *
+ * Find:  java.net.URLDecoder.decode("asdf")
+ * Without the parameter the default is the file.encoding system property so
+ * Charset.defaultCharset()
+ * URLDecoder.decode("asdf") is (nearly) the same as URLDecoder.decode("asdf",Charset.defaultCharset())
+ * But it is not really better (other than that you can see that it is depending on the default charset)
+ *
+ * KEEP
+ *
+ * Rewrite: java.net.URLDecoder.decode("asdf",Charset.defaultCharset())
+ *
+ * USE_UTF8
+ *
+ * Rewrite: java.net.URLDecoder.decode("asdf",StandardCharsets.UTF_8)
+ * This changes how the code works but it might be the better choice if you want to get rid of
+ * depending on environment settings
  */
 public class URLDecoderDecodeExplicitEncoding extends AbstractExplicitEncoding {
 
@@ -67,6 +84,24 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			operations.add(fixcore.rewrite(visited, cb, holder));
 			return false;
 		}
+		if (ASTNodes.usesGivenSignature(visited, URLDecoder.class.getCanonicalName(), METHOD_DECODE, String.class.getCanonicalName())) {
+			Nodedata nd=new Nodedata();
+			switch(cb) {
+				case KEEP:
+					nd.encoding=null;
+					break;
+				case USE_UTF8:
+					nd.encoding="UTF_8"; //$NON-NLS-1$
+					break;
+				case USE_UTF8_AGGREGATE:
+					break;
+			}
+			nd.replace=false;
+			nd.visited=visited;
+			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
+			return false;
+		}
 		return false;
 	}
 
@@ -86,7 +121,7 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 		 * Add Charset.defaultCharset() or StandardCharsets.UTF_8 as second (last) parameter
 		 */
 		ListRewrite listRewrite= rewrite.getListRewrite(visited, MethodInvocation.ARGUMENTS_PROPERTY);
-		if(((Nodedata)(data.get(visited))).encoding!= null) {
+		if(((Nodedata)(data.get(visited))).replace) {
 			listRewrite.replace(((Nodedata) data.get(visited)).visited, callToCharsetDefaultCharset, group);
 		} else {
 			listRewrite.insertLast(callToCharsetDefaultCharset, group);
@@ -96,10 +131,10 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 	@Override
 	public String getPreview(boolean afterRefactoring,ChangeBehavior cb) {
 		if(afterRefactoring) {
-			return "\"java.net.URLDecoder.decode(\"asdf\", StandardCharsets.UTF_8)\";\n"+ //$NON-NLS-1$
+			return "java.net.URLDecoder.decode(\"asdf\", StandardCharsets.UTF_8);\n"+ //$NON-NLS-1$
 					""; //$NON-NLS-1$
 		}
-		return "\"java.net.URLDecoder.decode(\"asdf\", \"UTF-8\")\";\n"+ //$NON-NLS-1$
+		return "java.net.URLDecoder.decode(\"asdf\", \"UTF-8\");\n"+ //$NON-NLS-1$
 		""; //$NON-NLS-1$
 	}
 }
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLEncoderEncodeExplicitEncoding.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLEncoderEncodeExplicitEncoding.java
index d6b300f9..a07b891f 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLEncoderEncodeExplicitEncoding.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/corext/fix/helper/URLEncoderEncodeExplicitEncoding.java
@@ -19,6 +19,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.eclipse.text.edits.TextEditGroup;
+
 import org.eclipse.jdt.core.dom.AST;
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -26,21 +28,36 @@
 import org.eclipse.jdt.core.dom.StringLiteral;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
+
 import org.eclipse.jdt.internal.corext.dom.ASTNodes;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.refactoring.structure.CompilationUnitRewrite;
 import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.text.edits.TextEditGroup;
 import org.sandbox.jdt.internal.common.HelperVisitor;
 import org.sandbox.jdt.internal.common.ReferenceHolder;
 import org.sandbox.jdt.internal.corext.fix.UseExplicitEncodingFixCore;
 /**
  * Java 10
- * 
+ *
  * Find:  java.net.URLEncoder.encode("asdf","UTF-8")
  *
  * Rewrite: java.net.URLEncoder.encode("asdf",StandardCharsets.UTF_8)
  *
+ * Find:  java.net.URLEncoder.encode("asdf")
+ * Without the parameter the default is the file.encoding system property so
+ * Charset.defaultCharset()
+ * URLEncoder.encode("asdf") is (nearly) the same as URLEncoder.encode("asdf",Charset.defaultCharset())
+ * But it is not really better (other than that you can see that it is depending on the default charset)
+ *
+ * KEEP
+ *
+ * Rewrite: java.net.URLEncoder.encode("asdf",Charset.defaultCharset())
+ *
+ * USE_UTF8
+ *
+ * Rewrite: java.net.URLEncoder.encode("asdf",StandardCharsets.UTF_8)
+ * This changes how the code works but it might be the better choice if you want to get rid of
+ * depending on environment settings
  */
 public class URLEncoderEncodeExplicitEncoding extends AbstractExplicitEncoding {
 
@@ -67,6 +84,24 @@ private static boolean processFoundNode(UseExplicitEncodingFixCore fixcore,
 			operations.add(fixcore.rewrite(visited, cb, holder));
 			return false;
 		}
+		if (ASTNodes.usesGivenSignature(visited, URLEncoder.class.getCanonicalName(), METHOD_ENCODE, String.class.getCanonicalName())) {
+			Nodedata nd=new Nodedata();
+			switch(cb) {
+				case KEEP:
+					nd.encoding=null;
+					break;
+				case USE_UTF8:
+					nd.encoding="UTF_8"; //$NON-NLS-1$
+					break;
+				case USE_UTF8_AGGREGATE:
+					break;
+			}
+			nd.replace=false;
+			nd.visited=visited;
+			holder.put(visited,nd);
+			operations.add(fixcore.rewrite(visited, cb, holder));
+			return false;
+		}
 		return false;
 	}
 
@@ -86,7 +121,7 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 		 * Add Charset.defaultCharset() as second (last) parameter
 		 */
 		ListRewrite listRewrite= rewrite.getListRewrite(visited, MethodInvocation.ARGUMENTS_PROPERTY);
-		if(((Nodedata)(data.get(visited))).encoding!= null) {
+		if(((Nodedata)(data.get(visited))).replace) {
 			listRewrite.replace(((Nodedata) data.get(visited)).visited, callToCharsetDefaultCharset, group);
 		} else {
 			listRewrite.insertLast(callToCharsetDefaultCharset, group);
@@ -96,10 +131,10 @@ public void rewrite(UseExplicitEncodingFixCore upp,final MethodInvocation visite
 	@Override
 	public String getPreview(boolean afterRefactoring,ChangeBehavior cb) {
 		if(afterRefactoring) {
-			return "\"java.net.URLEncoder.encode(\"asdf\", StandardCharsets.UTF_8)\";\n"+ //$NON-NLS-1$
+			return "java.net.URLEncoder.encode(\"asdf\", StandardCharsets.UTF_8);\n"+ //$NON-NLS-1$
 					""; //$NON-NLS-1$
 		}
-		return "\"java.net.URLEncoder.encode(\"asdf\", \"UTF-8\")\";\n"+ //$NON-NLS-1$
+		return "java.net.URLEncoder.encode(\"asdf\", \"UTF-8\");\n"+ //$NON-NLS-1$
 		""; //$NON-NLS-1$
 	}
 }
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUp.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUp.java
index cc036cbc..8329cd1c 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUp.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUp.java
@@ -13,48 +13,22 @@
  *******************************************************************************/
 package org.sandbox.jdt.internal.ui.fix;
 
+import java.util.Collections;
 import java.util.Map;
 
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.manipulation.ICleanUpFixCore;
-import org.eclipse.jdt.internal.ui.fix.AbstractCleanUp;
-import org.eclipse.jdt.internal.ui.fix.CleanUpFixWrapper;
-import org.eclipse.jdt.ui.cleanup.CleanUpContext;
-import org.eclipse.jdt.ui.cleanup.CleanUpOptions;
-import org.eclipse.jdt.ui.cleanup.CleanUpRequirements;
-import org.eclipse.jdt.ui.cleanup.ICleanUpFix;
+import org.eclipse.jdt.internal.ui.fix.AbstractCleanUpCoreWrapper;
 /**
  * Until
  * https://openjdk.java.net/jeps/400
  * is active platform encoding might be different than UTF-8.
  * So it can be dangerous not to use explicit encoding.
  */
-public class UseExplicitEncodingCleanUp extends AbstractCleanUp {
-	private final UseExplicitEncodingCleanUpCore coreCleanUp= new UseExplicitEncodingCleanUpCore();
+public class UseExplicitEncodingCleanUp extends AbstractCleanUpCoreWrapper {
 	public UseExplicitEncodingCleanUp(final Map options) {
-		setOptions(options);
+		super(options, new UseExplicitEncodingCleanUpCore());
 	}
+
 	public UseExplicitEncodingCleanUp() {
+		this(Collections.EMPTY_MAP);
 	}
-	@Override
-	public void setOptions(final CleanUpOptions options) {
-		coreCleanUp.setOptions(options);
-	}
-	@Override
-	public CleanUpRequirements getRequirements() {
-		return new CleanUpRequirements(coreCleanUp.getRequirementsCore());
-	}
-	@Override
-	public ICleanUpFix createFix(final CleanUpContext context) throws CoreException {
-		ICleanUpFixCore fixCore= coreCleanUp.createFixCore(context);
-		return fixCore == null ? null : new CleanUpFixWrapper(fixCore);
-	}
-	@Override
-	public String[] getStepDescriptions() {
-		return coreCleanUp.getStepDescriptions();
-	}
-	@Override
-	public String getPreview() {
-		return coreCleanUp.getPreview();
-	}
-}
+}
\ No newline at end of file
diff --git a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUpCore.java b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUpCore.java
index 8d9f704f..4b083b65 100644
--- a/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUpCore.java
+++ b/sandbox_encoding_quickfix/src/org/sandbox/jdt/internal/ui/fix/UseExplicitEncodingCleanUpCore.java
@@ -35,6 +35,7 @@
 import org.eclipse.jdt.core.manipulation.CleanUpContextCore;
 import org.eclipse.jdt.core.manipulation.CleanUpRequirementsCore;
 import org.eclipse.jdt.core.manipulation.ICleanUpFixCore;
+import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFix;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore;
 import org.eclipse.jdt.internal.corext.fix.CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation;
 import org.eclipse.jdt.internal.corext.util.Messages;
@@ -48,12 +49,14 @@ public UseExplicitEncodingCleanUpCore(final Map options) {
 	}
 	public UseExplicitEncodingCleanUpCore() {
 	}
+
 	@Override
 	public CleanUpRequirementsCore getRequirementsCore() {
 		return new CleanUpRequirementsCore(requireAST(), false, false, null);
 	}
+
 	public boolean requireAST() {
-		return isEnabled(EXPLICITENCODING_CLEANUP);
+		return isEnabled(EXPLICITENCODING_CLEANUP)&& !computeFixSet().isEmpty();
 	}
 	@Override
 	public ICleanUpFixCore createFixCore(final CleanUpContextCore context) throws CoreException {
@@ -73,7 +76,7 @@ public ICleanUpFixCore createFixCore(final CleanUpContextCore context) throws Co
 		if (operations.isEmpty()) {
 			return null;
 		}
-		return new CompilationUnitRewriteOperationsFixCore(ExplicitEncodingCleanUpFix_refactor,
+		return new CompilationUnitRewriteOperationsFix(ExplicitEncodingCleanUpFix_refactor,
 				compilationUnit, operations.toArray(new CompilationUnitRewriteOperationsFixCore.CompilationUnitRewriteOperation[0]));
 	}
 
@@ -118,4 +121,4 @@ private EnumSet computeFixSet() {
 		}
 		return fixSet;
 	}
-}
+}
\ No newline at end of file
diff --git a/sandbox_encoding_quickfix_test/src/org/eclipse/jdt/ui/tests/quickfix/Java10/ExplicitEncodingCleanUpTest.java b/sandbox_encoding_quickfix_test/src/org/eclipse/jdt/ui/tests/quickfix/Java10/ExplicitEncodingCleanUpTest.java
new file mode 100644
index 00000000..329d017b
--- /dev/null
+++ b/sandbox_encoding_quickfix_test/src/org/eclipse/jdt/ui/tests/quickfix/Java10/ExplicitEncodingCleanUpTest.java
@@ -0,0 +1,879 @@
+package org.eclipse.jdt.ui.tests.quickfix.Java10;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+import org.sandbox.jdt.internal.corext.fix2.MYCleanUpConstants;
+import org.sandbox.jdt.ui.tests.quickfix.rules.AbstractEclipseJava;
+import org.sandbox.jdt.ui.tests.quickfix.rules.EclipseJava10;
+
+public class ExplicitEncodingCleanUpTest {
+
+	@RegisterExtension
+	AbstractEclipseJava context = new EclipseJava10();
+
+	enum ExplicitEncodingPatterns {
+
+		CHARSET("""
+				package test1;
+
+				import java.io.ByteArrayOutputStream;
+				import java.io.InputStreamReader;
+				import java.io.FileInputStream;
+				import java.io.FileReader;
+				import java.io.Reader;
+				import java.nio.charset.Charset;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				        Charset cs1= Charset.forName("UTF-8");
+				        Charset cs1b= Charset.forName("Utf-8");
+				        Charset cs2= Charset.forName("UTF-16");
+				        Charset cs3= Charset.forName("UTF-16BE");
+				        Charset cs4= Charset.forName("UTF-16LE");
+				        Charset cs5= Charset.forName("ISO-8859-1");
+				        Charset cs6= Charset.forName("US-ASCII");
+				        String result= cs1.toString();
+				       }
+				    }
+				}
+				""",
+
+//					"""
+//						package test1;
+//
+//						import java.io.ByteArrayOutputStream;
+//						import java.io.InputStreamReader;
+//						import java.io.FileInputStream;
+//						import java.io.FileReader;
+//						import java.io.Reader;
+//						import java.nio.charset.Charset;
+//						import java.nio.charset.StandardCharsets;
+//						import java.io.FileNotFoundException;
+//
+//						public class E1 {
+//						    void method(String filename) {
+//						        Charset cs1= StandardCharsets.UTF_8;
+//						        Charset cs1b= StandardCharsets.UTF_8;
+//						        Charset cs2= StandardCharsets.UTF_16;
+//						        Charset cs3= StandardCharsets.UTF_16BE;
+//						        Charset cs4= StandardCharsets.UTF_16LE;
+//						        Charset cs5= StandardCharsets.ISO_8859_1;
+//						        Charset cs6= StandardCharsets.US_ASCII;
+//						        String result= cs1.toString();
+//						       }
+//						    }
+//						}
+//						"""),
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        Charset cs1= Charset.forName("UTF-8");
+						        Charset cs1b= Charset.forName("Utf-8");
+						        Charset cs2= Charset.forName("UTF-16");
+						        Charset cs3= Charset.forName("UTF-16BE");
+						        Charset cs4= Charset.forName("UTF-16LE");
+						        Charset cs5= Charset.forName("ISO-8859-1");
+						        Charset cs6= Charset.forName("US-ASCII");
+						        String result= cs1.toString();
+						       }
+						    }
+						}
+						"""),
+		BYTEARRAYOUTSTREAM("""
+				package test1;
+
+				import java.io.ByteArrayOutputStream;
+				import java.io.InputStreamReader;
+				import java.io.FileInputStream;
+				import java.io.FileReader;
+				import java.io.Reader;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				        ByteArrayOutputStream ba=new ByteArrayOutputStream();
+				        String result=ba.toString();
+				        ByteArrayOutputStream ba2=new ByteArrayOutputStream();
+				        String result2=ba2.toString("UTF-8");
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.nio.charset.StandardCharsets;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        ByteArrayOutputStream ba=new ByteArrayOutputStream();
+						        String result=ba.toString(Charset.defaultCharset());
+						        ByteArrayOutputStream ba2=new ByteArrayOutputStream();
+						        String result2=ba2.toString(StandardCharsets.UTF_8);
+						       }
+						    }
+						}
+						"""),
+		FILEREADER("""
+				package test1;
+
+				import java.io.InputStreamReader;
+				import java.io.FileInputStream;
+				import java.io.FileReader;
+				import java.io.Reader;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				        try {
+				            Reader is=new FileReader(filename);
+				            } catch (FileNotFoundException e) {
+				            e.printStackTrace();
+				            }
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        try {
+						            Reader is=new InputStreamReader(new FileInputStream(filename), Charset.defaultCharset());
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						"""),
+		FILEWRITER("""
+				package test1;
+
+				import java.io.FileWriter;
+				import java.io.Writer;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				        try {
+				            Writer fw=new FileWriter(filename);
+				            } catch (FileNotFoundException e) {
+				            e.printStackTrace();
+				            }
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.FileWriter;
+						import java.io.OutputStreamWriter;
+						import java.io.Writer;
+						import java.nio.charset.Charset;
+						import java.io.FileNotFoundException;
+						import java.io.FileOutputStream;
+
+						public class E1 {
+						    void method(String filename) {
+						        try {
+						            Writer fw=new OutputStreamWriter(new FileOutputStream(filename), Charset.defaultCharset());
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						"""),
+		INPUTSTREAMREADER(
+				"""
+						package test1;
+
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        try {
+						            InputStreamReader is1=new InputStreamReader(new FileInputStream("file1.txt")); //$NON-NLS-1$
+						            InputStreamReader is2=new InputStreamReader(new FileInputStream("file2.txt"), "UTF-8"); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						""",
+
+				"""
+						package test1;
+
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.nio.charset.StandardCharsets;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        try {
+						            InputStreamReader is1=new InputStreamReader(new FileInputStream("file1.txt"), Charset.defaultCharset()); //$NON-NLS-1$
+						            InputStreamReader is2=new InputStreamReader(new FileInputStream("file2.txt"), StandardCharsets.UTF_8); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						"""),
+		OUTPUTSTREAMWRITER(
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        try {
+						            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream("")); //$NON-NLS-1$
+						            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream(""), "UTF-8"); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						""",
+
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.nio.charset.StandardCharsets;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        try {
+						            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream(""), Charset.defaultCharset()); //$NON-NLS-1$
+						            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream(""), StandardCharsets.UTF_8); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						"""),
+		CHANNELSNEWREADER("""
+				package test1;
+
+				import java.io.ByteArrayOutputStream;
+				import java.io.InputStreamReader;
+				import java.io.FileInputStream;
+				import java.io.FileReader;
+				import java.io.Reader;
+				import java.nio.channels.ReadableByteChannel;
+				import java.nio.charset.StandardCharsets;
+				import java.nio.channels.Channels;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				            ReadableByteChannel ch;
+				            Reader r=Channels.newReader(ch,"UTF-8"); //$NON-NLS-1$
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.channels.ReadableByteChannel;
+						import java.nio.charset.StandardCharsets;
+						import java.nio.channels.Channels;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						            ReadableByteChannel ch;
+						            Reader r=Channels.newReader(ch,StandardCharsets.UTF_8); //$NON-NLS-1$
+						       }
+						    }
+						}
+						"""),
+		CHANNELSNEWWRITER("""
+				package test1;
+
+				import java.io.ByteArrayOutputStream;
+				import java.io.InputStreamReader;
+				import java.io.FileInputStream;
+				import java.io.FileReader;
+				import java.io.Writer;
+				import java.nio.channels.WritableByteChannel;
+				import java.nio.charset.StandardCharsets;
+				import java.nio.channels.Channels;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				            WritableByteChannel ch;
+				            Writer w=Channels.newWriter(ch,"UTF-8"); //$NON-NLS-1$
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Writer;
+						import java.nio.channels.WritableByteChannel;
+						import java.nio.charset.StandardCharsets;
+						import java.nio.channels.Channels;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						            WritableByteChannel ch;
+						            Writer w=Channels.newWriter(ch,StandardCharsets.UTF_8); //$NON-NLS-1$
+						       }
+						    }
+						}
+						"""),
+		PRINTWRITER("""
+				package test1;
+
+				import java.io.PrintWriter;
+				import java.io.Writer;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				        try {
+				            Writer w=new PrintWriter(filename);
+				            } catch (FileNotFoundException e) {
+				            e.printStackTrace();
+				            }
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.PrintWriter;
+						import java.io.Writer;
+						import java.nio.charset.Charset;
+						import java.io.BufferedWriter;
+						import java.io.FileNotFoundException;
+						import java.io.FileOutputStream;
+						import java.io.OutputStreamWriter;
+
+						public class E1 {
+						    void method(String filename) {
+						        try {
+						            Writer w=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), Charset.defaultCharset()));
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						"""),
+		STRINGGETBYTES("""
+				package test1;
+
+				import java.io.ByteArrayOutputStream;
+				import java.io.InputStreamReader;
+				import java.io.FileInputStream;
+				import java.io.FileReader;
+				import java.io.Reader;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				        String s="asdf"; //$NON-NLS-1$
+				        byte[] bytes= s.getBytes();
+				        byte[] bytes2= s.getBytes("UTF-8");
+				        System.out.println(bytes.length);
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.nio.charset.StandardCharsets;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        String s="asdf"; //$NON-NLS-1$
+						        byte[] bytes= s.getBytes(Charset.defaultCharset());
+						        byte[] bytes2= s.getBytes(StandardCharsets.UTF_8);
+						        System.out.println(bytes.length);
+						       }
+						    }
+						}
+						"""),
+		STRING("""
+				package test1;
+
+				import java.io.FileNotFoundException;
+				import java.io.UnsupportedEncodingException;
+
+				public class E5 {
+
+					static void bla() throws FileNotFoundException, UnsupportedEncodingException {
+						byte[] b= {(byte)59};
+						String s1=new String(b,"UTF-8");
+						String s2=new String(b,0,1,"UTF-8");
+					}
+				}
+										""",
+
+				"""
+						package test1;
+
+						import java.io.FileNotFoundException;
+						import java.io.UnsupportedEncodingException;
+						import java.nio.charset.StandardCharsets;
+
+						public class E5 {
+
+							static void bla() throws FileNotFoundException, UnsupportedEncodingException {
+								byte[] b= {(byte)59};
+								String s1=new String(b,StandardCharsets.UTF_8);
+								String s2=new String(b,0,1,StandardCharsets.UTF_8);
+							}
+						}
+														"""),
+		PROPERTIESSTORETOXML("""
+				package test1;
+
+				import java.io.FileOutputStream;
+				import java.io.IOException;
+				import java.util.Properties;
+
+				public class E1 {
+					static void blu() throws IOException {
+						Properties p=new Properties();
+						try (FileOutputStream os = new FileOutputStream("out.xml")) {
+							p.storeToXML(os, null, "UTF-8");
+						}
+						try (FileOutputStream os = new FileOutputStream("out.xml")) {
+							p.storeToXML(os, null);
+						}
+					}
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.FileOutputStream;
+						import java.io.IOException;
+						import java.nio.charset.StandardCharsets;
+						import java.util.Properties;
+
+						public class E1 {
+							static void blu() throws IOException {
+								Properties p=new Properties();
+								try (FileOutputStream os = new FileOutputStream("out.xml")) {
+									p.storeToXML(os, null, StandardCharsets.UTF_8);
+								}
+								try (FileOutputStream os = new FileOutputStream("out.xml")) {
+									p.storeToXML(os, null, StandardCharsets.UTF_8);
+								}
+							}
+						}
+												"""),
+		URLDECODER("""
+				package test1;
+				import java.io.UnsupportedEncodingException;
+				import java.net.URLDecoder;
+
+				public class E2 {
+
+					static void bla() throws UnsupportedEncodingException {
+						String url=URLDecoder.decode("asdf","UTF-8");
+						String url2=URLDecoder.decode("asdf");
+					}
+				}
+								""", """
+				package test1;
+				import java.io.UnsupportedEncodingException;
+				import java.net.URLDecoder;
+				import java.nio.charset.Charset;
+				import java.nio.charset.StandardCharsets;
+
+				public class E2 {
+
+					static void bla() throws UnsupportedEncodingException {
+						String url=URLDecoder.decode("asdf",StandardCharsets.UTF_8);
+						String url2=URLDecoder.decode("asdf", Charset.defaultCharset());
+					}
+				}
+												"""), 
+		URLENCODER("""
+				package test1;
+				import java.io.UnsupportedEncodingException;
+				import java.net.URLEncoder;
+
+				public class E2 {
+
+					static void bla() throws UnsupportedEncodingException {
+						String url=URLEncoder.encode("asdf","UTF-8");
+						String url4=URLEncoder.encode("asdf");
+					}
+				}
+								""", """
+				package test1;
+				import java.io.UnsupportedEncodingException;
+				import java.net.URLEncoder;
+				import java.nio.charset.Charset;
+				import java.nio.charset.StandardCharsets;
+
+				public class E2 {
+
+					static void bla() throws UnsupportedEncodingException {
+						String url=URLEncoder.encode("asdf",StandardCharsets.UTF_8);
+						String url4=URLEncoder.encode("asdf", Charset.defaultCharset());
+					}
+				}
+												"""), 
+		SCANNER("""
+				package test1;
+				import java.io.File;
+				import java.io.FileNotFoundException;
+				import java.util.Scanner;
+
+				public class E3 {
+
+					static void bla() throws FileNotFoundException {
+						Scanner s=new Scanner(new File("asdf"),"UTF-8");
+						Scanner s2=new Scanner("asdf","UTF-8");
+						Scanner s3=new Scanner("asdf");
+					}
+				}
+												""", """
+				package test1;
+				import java.io.File;
+				import java.io.FileNotFoundException;
+				import java.nio.charset.Charset;
+				import java.nio.charset.StandardCharsets;
+				import java.util.Scanner;
+
+				public class E3 {
+
+					static void bla() throws FileNotFoundException {
+						Scanner s=new Scanner(new File("asdf"),StandardCharsets.UTF_8);
+						Scanner s2=new Scanner("asdf",StandardCharsets.UTF_8);
+						Scanner s3=new Scanner("asdf", Charset.defaultCharset());
+					}
+				}
+								"""), 
+		FORMATTER("""
+				package test1;
+				import java.io.File;
+				import java.io.FileNotFoundException;
+				import java.io.UnsupportedEncodingException;
+				import java.util.Formatter;
+
+				public class E4 {
+
+					static void bla() throws FileNotFoundException, UnsupportedEncodingException {
+						Formatter s=new Formatter(new File("asdf"),"UTF-8");
+					}
+				}
+				""", """
+				package test1;
+				import java.io.File;
+				import java.io.FileNotFoundException;
+				import java.io.UnsupportedEncodingException;
+				import java.nio.charset.StandardCharsets;
+				import java.util.Formatter;
+
+				public class E4 {
+
+					static void bla() throws FileNotFoundException, UnsupportedEncodingException {
+						Formatter s=new Formatter(new File("asdf"),StandardCharsets.UTF_8);
+					}
+				}
+								"""), 
+		THREE("""
+				package test1;
+
+				import java.io.ByteArrayOutputStream;
+				import java.io.InputStreamReader;
+				import java.io.FileInputStream;
+				import java.io.FileReader;
+				import java.io.Reader;
+				import java.io.FileNotFoundException;
+
+				public class E1 {
+				    void method(String filename) {
+				        String s="asdf"; //$NON-NLS-1$
+				        byte[] bytes= s.getBytes();
+				        System.out.println(bytes.length);
+				        ByteArrayOutputStream ba=new ByteArrayOutputStream();
+				        String result=ba.toString();
+				        try {
+				            InputStreamReader is=new InputStreamReader(new FileInputStream("")); //$NON-NLS-1$
+				            } catch (FileNotFoundException e) {
+				            e.printStackTrace();
+				            }
+				        try {
+				            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream("")); //$NON-NLS-1$
+				            } catch (FileNotFoundException e) {
+				            e.printStackTrace();
+				            }
+				        try {
+				            Reader is=new FileReader(filename);
+				            } catch (FileNotFoundException e) {
+				            e.printStackTrace();
+				            }
+				       }
+				    }
+				}
+				""",
+
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        String s="asdf"; //$NON-NLS-1$
+						        byte[] bytes= s.getBytes(Charset.defaultCharset());
+						        System.out.println(bytes.length);
+						        ByteArrayOutputStream ba=new ByteArrayOutputStream();
+						        String result=ba.toString(Charset.defaultCharset());
+						        try {
+						            InputStreamReader is=new InputStreamReader(new FileInputStream(""), Charset.defaultCharset()); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						        try {
+						            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream(""), Charset.defaultCharset()); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						        try {
+						            Reader is=new InputStreamReader(new FileInputStream(filename), Charset.defaultCharset());
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						"""),
+		ENCODINGASSTRINGPARAMETER(
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        String s="asdf"; //$NON-NLS-1$
+						        //byte[] bytes= s.getBytes(StandardCharsets.UTF_8);
+						        byte[] bytes= s.getBytes("Utf-8");
+						        System.out.println(bytes.length);
+						        ByteArrayOutputStream ba=new ByteArrayOutputStream();
+						        String result=ba.toString();
+						        try {
+						            InputStreamReader is=new InputStreamReader(new FileInputStream(""), "UTF-8"); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						        try {
+						            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream(""), "UTF-8"); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						        try {
+						            Reader is=new FileReader(filename);
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						""",
+
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.FileInputStream;
+						import java.io.FileReader;
+						import java.io.Reader;
+						import java.nio.charset.Charset;
+						import java.nio.charset.StandardCharsets;
+						import java.io.FileNotFoundException;
+
+						public class E1 {
+						    void method(String filename) {
+						        String s="asdf"; //$NON-NLS-1$
+						        //byte[] bytes= s.getBytes(StandardCharsets.UTF_8);
+						        byte[] bytes= s.getBytes(StandardCharsets.UTF_8);
+						        System.out.println(bytes.length);
+						        ByteArrayOutputStream ba=new ByteArrayOutputStream();
+						        String result=ba.toString(Charset.defaultCharset());
+						        try {
+						            InputStreamReader is=new InputStreamReader(new FileInputStream(""), StandardCharsets.UTF_8); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						        try {
+						            OutputStreamWriter os=new OutputStreamWriter(new FileOutputStream(""), StandardCharsets.UTF_8); //$NON-NLS-1$
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						        try {
+						            Reader is=new InputStreamReader(new FileInputStream(filename), Charset.defaultCharset());
+						            } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						       }
+						    }
+						}
+						""");
+
+		String given;
+		String expected;
+
+		ExplicitEncodingPatterns(String given, String expected) {
+			this.given = given;
+			this.expected = expected;
+		}
+	}
+
+	@ParameterizedTest
+	@EnumSource(ExplicitEncodingPatterns.class)
+	public void testExplicitEncodingParametrized(ExplicitEncodingPatterns test) throws CoreException {
+		IPackageFragment pack = context.getfSourceFolder().createPackageFragment("test1", false, null);
+		ICompilationUnit cu = pack.createCompilationUnit("E1.java", test.given, false, null);
+		context.enable(MYCleanUpConstants.EXPLICITENCODING_CLEANUP);
+		context.assertRefactoringResultAsExpected(new ICompilationUnit[] { cu }, new String[] { test.expected }, null);
+	}
+
+	@Test
+	public void testExplicitEncodingdonttouch() throws CoreException {
+		IPackageFragment pack = context.getfSourceFolder().createPackageFragment("test1", false, null);
+		ICompilationUnit cu = pack.createCompilationUnit("E2.java",
+				"""
+						package test1;
+
+						import java.io.ByteArrayOutputStream;
+						import java.io.InputStreamReader;
+						import java.io.IOException;
+						import java.nio.charset.Charset;
+						import java.io.FileInputStream;
+						import java.io.FileNotFoundException;
+						import java.io.UnsupportedEncodingException;
+
+						public class E2 {
+						    void method() throws UnsupportedEncodingException, IOException {
+						        String s="asdf"; //$NON-NLS-1$
+						        byte[] bytes= s.getBytes(Charset.defaultCharset());
+						        System.out.println(bytes.length);
+						        ByteArrayOutputStream ba=new ByteArrayOutputStream();
+						        String result=ba.toString(Charset.defaultCharset().displayName());
+						        try (
+						            InputStreamReader is=new InputStreamReader(new FileInputStream(""), Charset.defaultCharset()); //$NON-NLS-1$
+						           ){ } catch (FileNotFoundException e) {
+						            e.printStackTrace();
+						            }
+						    }
+						}
+						""",
+				false, null);
+
+		context.enable(MYCleanUpConstants.EXPLICITENCODING_CLEANUP);
+
+		context.assertRefactoringHasNoChange(new ICompilationUnit[] { cu });
+	}
+}