⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringutils.java

📁 是一个专门设计用于触摸屏的POS(point of sales)应用软件
💻 JAVA
字号:
//    Tina POS is a point of sales application designed for touch screens.//    Copyright (C) 2005 Adrian Romero Corchado.//    http://sourceforge.net/projects/tinapos////    This program is free software; you can redistribute it and/or modify//    it under the terms of the GNU General Public License as published by//    the Free Software Foundation; either version 2 of the License, or//    (at your option) any later version.////    This program is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//    GNU General Public License for more details.////    You should have received a copy of the GNU General Public License//    along with this program; if not, write to the Free Software//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USApackage net.adrianromero.tpv.util;public class StringUtils {         private static final char [] hexchars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};         /** Creates a new instance of StringUtils */    private StringUtils() {    }        public static String encodeXML(String sValue) {                if (sValue == null) {            return null;        } else {            StringBuffer buffer = new StringBuffer();                  for (int i = 0; i < sValue.length(); i++) {                char charToCompare = sValue.charAt(i);                if (charToCompare == '&') {                    buffer.append("&amp;");                } else if (charToCompare == '<') {                    buffer.append("&lt;");                } else if (charToCompare == '>') {                    buffer.append("&gt;");                } else if (charToCompare == '\"') {                    buffer.append("&quot;");                } else if (charToCompare == '\'') {                    buffer.append("&apos;");                } else {                    buffer.append(charToCompare);                }            }            return buffer.toString();        }    }          public static String byte2hex(byte[] binput) {                StringBuffer sb = new StringBuffer(binput.length * 2);        for (int i = 0; i < binput.length; i++) {            int high = ((binput[i] & 0xF0) >> 4);            int low = (binput[i] & 0x0F);            sb.append(hexchars[high]);            sb.append(hexchars[low]);        }        return sb.toString();    }        public static byte [] hex2byte(String sinput) {        int length = sinput.length();        if ((length & 0x01) != 0) {            throw new IllegalArgumentException("odd number of characters.");        }        byte[] out = new byte[length >> 1];        // two characters form the hex value.        for (int i = 0, j = 0; j < length; i++) {            int f = Character.digit(sinput.charAt(j++), 16) << 4;            f = f | Character.digit(sinput.charAt(j++), 16);            out[i] = (byte) (f & 0xFF);        }        return out;    }        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -