Search This Blog

Showing posts with label bytes. Show all posts
Showing posts with label bytes. Show all posts

Friday, September 25, 2020

Java Contains Byte String - Back to Original Content String from Byte Array String

Code


String str = "hello";
byte [] x = str.getBytes ();
System.out.println ( new String (x) );
String byStr = "104, 101, 108, 108, 111";
String a [] = byStr.split ( "," );
byte xx [] = new byte[a.length];
int count = 0;
for ( String s :  a)
{
xx[count++] = Byte.parseByte ( s.trim () );
}
System.out.println ( new String (xx) );


Output

hello

hello




Wednesday, May 8, 2019

ObjectMapper - read JSON list to VO object

ObjectMapper mapper = new ObjectMapper ();

mapper.enable ( DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY );
mapper.configure ( JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true );

List queryBuilderVOList = Arrays.asList ( mapper.readValue ( mapper.writeValueAsString ( map.get ( "data" ) ).getBytes (), QueryBuilderVO [].class ) );

Hit Counter


View My Stats