Java Byte Array from getBytes(String defaultPlain)

Here you can find the source of getBytes(String defaultPlain)

Description

get Bytes

License

Open Source License

Declaration

public static byte[] getBytes(String defaultPlain) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class Main {
    public static byte[] getBytes(String defaultPlain) {
        byte[] data = null;
        while (true) {
            System.out.print("Please Input Data \"" + defaultPlain + "\"(default): ");
            try {
                String str = new BufferedReader(new InputStreamReader(System.in)).readLine();
                if ("".equals(str)) {
                    data = defaultPlain.getBytes();
                } else {
                    data = str.getBytes();
                }/*from w ww  . j av a 2 s. c o  m*/
                break;
            } catch (Exception e) {
                data = defaultPlain.getBytes();
            }
        }

        return data;
    }
}

Related

  1. getBytes(final String value, final String characterEncoding)
  2. getBytes(int length, InputStream inStream)
  3. getBytes(int value)
  4. getBytes(String content)
  5. getBytes(String data, String encoding)
  6. getBytes(String fileName)
  7. getBytes(String fileName)
  8. getBytes(String filePath)
  9. getBytes(String filePath, long startPos, long endPos)