MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / StringData

Class StringData

CodenameOne/src/com/codename1/io/Data.java:59–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 long getSize() throws IOException;
58
59 class StringData implements Data {
60 private final byte[] bytes;
61
62 public StringData(String str) {
63 this(str, "UTF-8");
64 }
65
66 public StringData(String str, String charset) {
67 try {
68 bytes = str.getBytes(charset);
69 } catch (UnsupportedEncodingException ex) {
70 Log.e(ex);
71 throw new RuntimeException("Failed to create StringData with encoding " + charset, ex);
72 }
73 }
74
75 @Override
76 public void appendTo(OutputStream output) throws IOException {
77 output.write(bytes);
78 }
79
80 @Override
81 public long getSize() throws IOException {
82 return bytes.length;
83 }
84
85 }
86
87 /// Wraps a File as a Data object.
88 ///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected