Java Byte to Char byteToChar(int b, char unprintable)

Here you can find the source of byteToChar(int b, char unprintable)

Description

Translate the byte into an ASCII char if it is printable.

License

Academic Free License

Declaration

public static char byteToChar(int b, char unprintable) 

Method Source Code

//package com.java2s;
// Licensed under the Academic Free License version 3.0

public class Main {
    /**//from   w w w  .  j a  v a  2  s . c  o m
     * Translate the byte into an ASCII char if it
     * is printable.  If not return the given
     * unprintable char.
     */
    public static char byteToChar(int b, char unprintable) {
        if ((b < 32) || (b > 126))
            return unprintable;
        else
            return (char) b;
    }
}

Related

  1. byteToChar(byte b)
  2. byteToChar(byte b_)
  3. byteToChar(byte c)
  4. byteToChar(byte chr)
  5. byteToChar(byte[] bytes)
  6. ByteToSafeChar(byte _bt)
  7. charAt(byte[] b, int s)