Skip to content

Commit dacc3dc

Browse files
adwsinghrhernandez35
authored andcommitted
Use Files.write
1 parent b07d9d3 commit dacc3dc

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

io/src/main/java/software/amazon/smithy/java/io/ByteBufferUtils.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import java.io.InputStream;
99
import java.nio.ByteBuffer;
10-
import java.nio.charset.Charset;
11-
import java.nio.charset.StandardCharsets;
1210
import java.util.Base64;
1311

1412
public final class ByteBufferUtils {
@@ -35,15 +33,6 @@ public static byte[] getBytes(ByteBuffer buffer) {
3533
return bytes;
3634
}
3735

38-
public static String asString(ByteBuffer buffer) {
39-
return asString(buffer, StandardCharsets.UTF_8);
40-
}
41-
42-
public static String asString(ByteBuffer buffer, Charset charset) {
43-
byte[] bytes = getBytes(buffer);
44-
return new String(bytes, charset);
45-
}
46-
4736
public static InputStream byteBufferInputStream(ByteBuffer buffer) {
4837
return new ByteBufferBackedInputStream(buffer);
4938
}

mcp/mcp-cli-api/src/main/java/software/amazon/smithy/java/mcp/cli/ConfigUtils.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ static Path getBundleFileLocation(String bundleName) {
9999
* @throws IOException If there's an error writing to the file
100100
*/
101101
public static void updateConfig(Config config) throws IOException {
102-
var file = CONFIG_PATH.toFile();
103-
try (var writer = new FileWriter(file, StandardCharsets.UTF_8)) {
104-
writer.write(ByteBufferUtils.asString(JSON_CODEC.serialize(config)));
105-
}
102+
Files.write(CONFIG_PATH, toJson(config), StandardOpenOption.CREATE_NEW);
106103
}
107104

108105
/**

0 commit comments

Comments
 (0)