Skip to content

io microsphere io StringDeserializer

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

StringDeserializer

Type: Class | Module: microsphere-java-core | Package: io.microsphere.io | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/io/StringDeserializer.java

Overview

A Deserializer implementation for converting byte arrays into String instances.

This class uses a specified Charset to decode the byte array into a string. If no charset is provided, it defaults to using UTF-8.

Thread Safety

This implementation is thread-safe as it does not maintain any internal state that may be modified after construction.

Example Usage

`// Using default charset (UTF-8)
Deserializer deserializer = new StringDeserializer();
String result = deserializer.deserialize("Hello, World!".getBytes(StandardCharsets.UTF_8));
System.out.println(result); // Output: Hello, World!
`
`// Using custom charset (e.g., ISO-8859-1)
Deserializer deserializer = new StringDeserializer(StandardCharsets.ISO_8859_1);
String result = deserializer.deserialize("Sample".getBytes(StandardCharsets.ISO_8859_1));
System.out.println(result); // Output: Sample
`

Declaration

public class StringDeserializer implements Deserializer<String>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Example 1

// Using default charset (UTF-8)
Deserializer<String> deserializer = new StringDeserializer();
String result = deserializer.deserialize("Hello, World!".getBytes(StandardCharsets.UTF_8));
System.out.println(result); // Output: Hello, World!

Example 2

// Using custom charset (e.g., ISO-8859-1)
Deserializer<String> deserializer = new StringDeserializer(StandardCharsets.ISO_8859_1);
String result = deserializer.deserialize("Sample".getBytes(StandardCharsets.ISO_8859_1));
System.out.println(result); // Output: Sample

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.io.StringDeserializer;

API Reference

Public Methods

Method Description
deserialize

See Also

  • Deserializer
  • Serializer

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally