private static String toAsciiString ( byte [ ] bytes ) { for ( int i = 0 ; i < bytes . length ; i ++ ) { if ( bytes [ i ] < 0 ) return null ; } char [ ] chars = new char [ bytes . length ] ; for ( int i = 0 ; i < bytes . length ; i ++ ) { chars [ i ] = ( char ) bytes [ i ] ; } return new String ( chars ) ; }
return string if bytes have only ascii symbols or null