u盘优盘损坏数据恢复打不开怎么办

14:13 提问
如何判断一个特殊字符是英文的还是中文的?
我这里要做一个输入的判断,汉字、英文和数字我都能识别出,特殊字符里面分有中文和英文的,不知道怎么区别,各位有没有什么方法解决?
按赞数排序
String str = "我爱你,xr.";
char[] array = str.toCharArray();
int chineseCount = 0;
int englishCount = 0;
for (int i = 0; i & array. i++) {
if((char)(byte)array[i]!=array[i]){
chineseCount++;
englishCount++;
这个是加入计数后的代码
可以计算中文字符和英文字符个数
其中中文字符包含汉子
英文字符包含字母
String s="你";
if(String.valueOf(s.charAt(0)).getBytes().length==2){
System.out.println("是中文");
System.out.println("不是中文");
中文的字符ASCII码值在128—255之间(或者是小于零,中文字符一般占用两个字节),英文的字符ASCII码值在0—128之间。
String ss = "你";
Pattern pile("[\u4e00-\u9fa5]");
Matcher matcher=pattern.matcher(ss);
matcher为true是中文
char[] myChar = s.toCharArray();
for (int i = 0; i & myChar. i++) {
if ((char) (byte) myChar[i] != myChar[i]) {
//中文相关字符
试一下这个看看可以么
public static String distinguish(String src) {
String result = "";
p = pile("[\u4e00-\u9fa5]");
m = p.matcher(src);
if (m.find()) {
result = result + "有汉字
p = pile("[a-zA-Z]");
m = p.matcher(src);
if (m.find()) {
result = result + "有字母
p = pile("[0-9]");
m = p.matcher(src);
if (m.find()) {
result = result + "有数字
p = pile("\\p{Punct}");
m = p.matcher(src);
if (m.find()) {
result = result + "有标点符号
int[] params = SmsMessage.calculateLength(text, false);
/* SmsMessage.calculateLength returns an int[4] with:
int[0] being the number of SMS's required,
int[1] the number of code units used,
int[2] is the number of code units remaining until the next message.
int[3] is the encoding type that should be used for the message.
android Mms的源码里是用这个判断的
int[3]是你要参考的值, 只是感觉这么做对你的需求来说有点麻烦了
不知道这样有没有用,可以试试正则表达式
boolean result = yourString.contains("[-+.^:,]");
这个方法检测特殊字符:
Pattern p = pile("[&%$#@!()*^]"); //&---- you can add more characters to check here
Matcher m = p.matcher(myEditText2);
if (m.find()) {
editText.setError("you can not enter special Character");
import java.util.regex.M
import java.util.regex.P
其他相似问题java判断一个字符是否是汉字,一个字符串中是否含有汉字-java判断输入的字符串中是否包含某个字符 _汇潮装饰网
您当前位置:
java判断一个字符是否是汉字,一个字符串中是否含有汉字
java判断一个字符是否是汉字,一个字符串中是否含有汉字
中&quot.println(), &
String str = &quot.println(p;/).matches(regEx.PInternet 网络 is 真好 very
/)).find()) {
/public class test {public static void main(String[] args) {
int count = 0;
S\)).out.matches(regEx;
String regEx = &quot.regex!&提取出来的中文有;&#47:&quot.
Pattern p = P
while (m;);[\
S\ &quot, &import java.group(0)+&quot. System.println(str).println(regEx).pile(regEx);.util.matcher(str).println(p; System.print(m.Matcher.util.print(&
Matcher m =a&u4e00-&#92.
Su9fa5]&quot.out.
中&quot.println(), &
String str = &quot.println(p;/).matches(regEx.PInternet 网络 is 真好 very
/)).find()) {
/public class test {public static void main(String[] args) {
int count = 0;
S\)).out.matches(regEx;
String regEx = &quot.regex!&提取出来的中文有;&#47:&quot.
Pattern p = P
while (m;);[\
S\ &quot, &import java.group(0)+&quot. System.println(str).println(regEx).pile(regEx);.util.matcher(str).println(p; System.print(m.Matcher.util.print(&
Matcher m =a&u4e00-&#92.
Su9fa5]&quot.out.
用正则表达式
用取余运算来判断一个数能否被整除,如果n除以m的余数为零,我们说n可以被m整除 具体的判断方法是 i...)
boolean a = s.contains(&??&);)
Class clazzA = A. Class clazzB = B. bo...)
float f= 1.2f;int i=(int)f;if(i==f)System.out.prin...)
1.使用Character.isDigit(char)判断 char num[] = str.toC...)
import java.util.Cimport java.util.Scanner...)
if(z == int (z)){ prt(&整形&) } 或者 整型/整型=整型 所以结果Z一定是...)
public class Test { //输入年份判断是否为闰年public static voi...)
有个contains方法可以判断是否在集合里面)

我要回帖

更多关于 u盘坏了数据恢复 的文章

 

随机推荐