diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java index 752ef58bce5b..60421ed33ff6 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/RangeMarkerTest.java @@ -39,6 +39,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.lang.ref.Reference; import java.lang.ref.WeakReference; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicInteger; @@ -874,22 +875,22 @@ public class RangeMarkerTest extends LightPlatformTestCase { private static void printFailingSteps(List> adds, List> dels, List> edits) { - String s = "adds: "; + StringBuilder s = new StringBuilder("adds: "); for (Pair c : adds) { TextRange t = c.second; - s += t.getStartOffset() + "," + t.getEndOffset() + ", "; + s.append(t.getStartOffset()).append(",").append(t.getEndOffset()).append(", "); } - s += "\nedits: "; + s.append("\nedits: "); for (Trinity edit : edits) { - s += edit.first + "," + edit.second + "," + edit.third + ", "; + s.append(edit.first).append(",").append(edit.second).append(",").append(edit.third).append(", "); } - s += "\ndels: "; + s.append("\ndels: "); for (Pair c : dels) { int index = adds.indexOf(c); assertSame(c, adds.get(index)); - s += index + ", "; + s.append(index).append(", "); } System.err.println(s); } @@ -1374,7 +1375,7 @@ public class RangeMarkerTest extends LightPlatformTestCase { String newText = "0123blah"; WriteCommandAction.runWriteCommandAction(getProject(), (ThrowableComputable)()->{ - vf.setBinaryContent(newText.getBytes("utf-8")); + vf.setBinaryContent(newText.getBytes(StandardCharsets.UTF_8)); return null; }); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/fs/LazyAttachVirtualFS.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/fs/LazyAttachVirtualFS.java index 902ea75a43db..7327a698e4bf 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/fs/LazyAttachVirtualFS.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/fs/LazyAttachVirtualFS.java @@ -3,7 +3,10 @@ package com.intellij.xdebugger.attach.fs; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileListener; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.util.IncorrectOperationException; import com.intellij.xdebugger.attach.EnvironmentAwareHost; import org.jetbrains.annotations.NonNls; @@ -12,6 +15,7 @@ import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -129,6 +133,6 @@ public class LazyAttachVirtualFS extends VirtualFileSystem { return null; } - return new String(FileUtil.loadBytes(stream), CharsetToolkit.UTF8); + return new String(FileUtil.loadBytes(stream), StandardCharsets.UTF_8); } } diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/decompiler/ConsoleDecompiler.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/decompiler/ConsoleDecompiler.java index 47609fae99c1..684249ef3b2b 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/decompiler/ConsoleDecompiler.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/main/decompiler/ConsoleDecompiler.java @@ -172,7 +172,7 @@ public class ConsoleDecompiler implements IBytecodeProvider, IResultSaver { @Override public void saveClassFile(String path, String qualifiedName, String entryName, String content, int[] mapping) { File file = new File(getAbsolutePath(path), entryName); - try (Writer out = new OutputStreamWriter(new FileOutputStream(file), "UTF8")) { + try (Writer out = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) { out.write(content); } catch (IOException ex) { diff --git a/python/ipnb/src/org/jetbrains/plugins/ipnb/protocol/IpnbConnection.java b/python/ipnb/src/org/jetbrains/plugins/ipnb/protocol/IpnbConnection.java index ee3344b48936..363aca03a0f1 100644 --- a/python/ipnb/src/org/jetbrains/plugins/ipnb/protocol/IpnbConnection.java +++ b/python/ipnb/src/org/jetbrains/plugins/ipnb/protocol/IpnbConnection.java @@ -122,7 +122,7 @@ public class IpnbConnection { if (myXsrf == null) { initXSRF(myURI.toString() + USER_PATH + "/" + username + TREE_PATH); } - final Boolean started = startJupyterNotebookServer(username); + final boolean started = startJupyterNotebookServer(username); if (!started) { throw new IOException(CANNOT_START_JUPYTER); } @@ -469,8 +469,7 @@ public class IpnbConnection { @NotNull private static String getResponse(HttpURLConnection connection) throws IOException { - final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8")); - try { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { final StringBuilder builder = new StringBuilder(); char[] buffer = new char[4096]; int n; @@ -480,7 +479,6 @@ public class IpnbConnection { return builder.toString(); } finally { - reader.close(); connection.disconnect(); } }