View Javadoc
1   package com.github.davidmoten.rx2.buffertofile;
2   
3   import java.io.IOException;
4   import java.nio.charset.Charset;
5   
6   public final class SerializerString implements Serializer<String> {
7   
8       private final Charset charset;
9   
10      public SerializerString(Charset charset) {
11          this.charset = charset;
12      }
13  
14      @Override
15      public byte[] serialize(String s) throws IOException {
16          return s.getBytes(charset);
17      }
18  
19      @Override
20      public String deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
21          return new String(bytes, charset);
22      }
23  
24  }