java实验一ATM心得
2013-09-25 20:00
246 查看
1.得到系统现在时间并按格式输出的函数
//返回时间字符串
public String getCurrentTime()
{
SimpleDateFormat sdf = new SimpleDateFormat("",Locale.SIMPLIFIED_CHINESE);
sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
return sdf.format(new Date());
}
最前面包括import java.text.SimpleDateFormat;
2.熟练运用tostring()
3.substring(str,a,b)
str 是你要截取的字符串所在的字符串;a是从哪里开始截取;b是从哪开始不截取了
4.读文件
FileReader fr = new FileReader("UserInfo.txt");
BufferedReader br = new BufferedReader(fr);
写文件
FileWriter fw = new FileWriter("userInfo.txt");
BufferedWriter bw = new BufferedWriter(fw);
对br bw进行操作
5.Scanner in = new Scanner(str1).useDelimiter("#");
这个语句能使in.next()遇到#不读了 代替了原来的遇到“ ”不读了
6.正则表达式
//判断密码每位是否相同
public boolean isright(String key)
{
String str = key.substring(0,1) + "{" + key.length() + "}";
if(key.matches(str))
return false;
else
return true;
}
这里str就是正则表达式,运用了matches函数进行比较
7.范型列表
ArrayList<String> strList = new ArrayList<String>();
和数组的使用方式差不多
8.newLine()把光标移到下一行
9.in.next()如果读不到内容就会抛出异常
//返回时间字符串
public String getCurrentTime()
{
SimpleDateFormat sdf = new SimpleDateFormat("",Locale.SIMPLIFIED_CHINESE);
sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
return sdf.format(new Date());
}
最前面包括import java.text.SimpleDateFormat;
2.熟练运用tostring()
3.substring(str,a,b)
str 是你要截取的字符串所在的字符串;a是从哪里开始截取;b是从哪开始不截取了
4.读文件
FileReader fr = new FileReader("UserInfo.txt");
BufferedReader br = new BufferedReader(fr);
写文件
FileWriter fw = new FileWriter("userInfo.txt");
BufferedWriter bw = new BufferedWriter(fw);
对br bw进行操作
5.Scanner in = new Scanner(str1).useDelimiter("#");
这个语句能使in.next()遇到#不读了 代替了原来的遇到“ ”不读了
6.正则表达式
//判断密码每位是否相同
public boolean isright(String key)
{
String str = key.substring(0,1) + "{" + key.length() + "}";
if(key.matches(str))
return false;
else
return true;
}
这里str就是正则表达式,运用了matches函数进行比较
7.范型列表
ArrayList<String> strList = new ArrayList<String>();
和数组的使用方式差不多
8.newLine()把光标移到下一行
9.in.next()如果读不到内容就会抛出异常
相关文章推荐
- 哈工大 java实验1 ATM系统的编写
- Python实现HIT软件学院Java第一次实验(模拟ATM过程)
- Java实验一---模拟ATM
- 【Java】实验三
- 关于用java编写生成word文档,动态添加数据到word文档的一些心得
- java(C语言实验——时间间隔)
- Java心得--集合、列表
- 网页图片验证码实验心得
- Java心得---表达式、流程控制
- Java实验报告(实验四)
- [转]Java/JSP中文乱码问题解决心得
- 实验一 Java开发环境的熟悉(Linux+Eclipse)
- java程序 升级版ATM取款机
- 实验1:java开发环境的熟悉
- java实验一 20135106宋世超
- java 学习心得体会(二)
- java中的移位运算符心得总结
- Java运用心得(二)
- Java实验一
- java实验打包下载