Skip to content

io microsphere io StringSerializer

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

StringSerializer

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

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

Overview

A Serializer implementation for converting String objects into byte arrays using a specified charset.

This class provides a thread-safe mechanism for serializing strings. By default, it uses UTF-8 encoding if no specific charset is provided during construction.

Example Usage

`// Using the default UTF-8 charset
Serializer serializer = new StringSerializer();
byte[] bytes = serializer.serialize("Hello, World!");

// Using a custom charset
Serializer serializerWithCharset = new StringSerializer(StandardCharsets.ISO_8859_1);
byte[] customEncodedBytes = serializerWithCharset.serialize("Sample Text");
`

Declaration

public class StringSerializer implements Serializer<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

// Using the default UTF-8 charset
Serializer<String> serializer = new StringSerializer();
byte[] bytes = serializer.serialize("Hello, World!");

// Using a custom charset
Serializer<String> serializerWithCharset = new StringSerializer(StandardCharsets.ISO_8859_1);
byte[] customEncodedBytes = serializerWithCharset.serialize("Sample Text");

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.StringSerializer;

API Reference

Public Methods

Method Description
serialize

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