我刚好在看IO流
你可以这样做:
DataInputStream in=new DataInputStream(new StringBufferInputStream(objString));
int c;
boolean right=true;
while((c=in.read())!=-1)
if(c>=65&&c<=96)//抱歉,ASCII码忘了,反正就是大小写的字母和数字之间的范围
continue;
else
right=false;
return right;
你可以这样做:
DataInputStream in=new DataInputStream(new StringBufferInputStream(objString));
int c;
boolean right=true;
while((c=in.read())!=-1)
if(c>=65&&c<=96)//抱歉,ASCII码忘了,反正就是大小写的字母和数字之间的范围
continue;
else
right=false;
return right;
解决方案 »
- java环境下运行模型检测工具Spin遇到的问题(新手求教)
- 一个关于Jsp的问题
- 想翻译 第七版 《Java核心技术 卷II:高级特性》,目前已翻译第一章前四节
- 求救高手!!在线苦等。。。。。
- "Frame1.java": Fatal Error: Unable to locate package java.lang in classpath or bootclasspath是怎么回事啊??
- HashMap与IdentityHashMap
- http://www.wireless2k.com,通过手机进行远程控制
- 哪里可以找到java的中文帮助信息
- Java的类是否区分大小写?
- 请问各位大虾,如何把一个String赋值给一个Char[]??
- 聊天室里的滚动条自动下来是怎么做的?
- 毕业设计的最新要求,关于JAVA3D,答对就给分
String s="你得到的字符串";
s.getBytes("iso8859-1");
System.out.println("字符串不包含中文");
}catch(Exception e){
System.out.println("字符串包含中文");
}
//这个方法是判断字符时候包含中文String tag="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
String s="你得到的字符串";
for(int i=0;i<s.length();i++){
if(tag.indexOf(s[i])<0)
System.out.println("字符串包括其他的字符");
}
//这是判断字符是否全有0-9,a-z ,A-Z 组成祝你好运!
对于数字的判断,
String s = "456555";
Pattern p = Pattern.compile("[0-9]*");
Matcher m = p.matcher(s);
boolean b = m.matches();
对于字母的判断,
String s="JHubebmnd";
Pattern p = Pattern.compile("[a-z,A-Z]*");
Matcher m = p.matcher(s);
boolean b = m.matches();
import java.util.regex.*;public class Regex
{
public static void main(String[] args)
{
Pattern p = Pattern.compile("[0-9]*");
Pattern p1=Pattern.compile("[a-z]*");
Matcher m = p.matcher(args[0]);
boolean b = m.matches();
if(b)
System.out.println(args[0]+" is number");
m=p1.matcher(args[0]);
boolean b1=m.matches();
if(b1)
System.out.println(args[0]+" is character");
if(!b&&!b1)
System.out.println(args[0]+" is neither number nor character");
}
}
// 字母或数字 (字母或数字的UTF-8编码的长度和其ASCII编码的长度一样)
} else {
// 至少有一个多字节字付
}