我的文件名是:
20050701.txt
20050702.txt
20050703.txt
20050704.txt
20050705.txt
20050706.txt
20050707.txt
第一个文件内容是:
ST:20050701 000011 TI:20050719 000011 CN:06 LT:10 PN:13099885853 DN:1015902210 AR:D KC:- RS:@!!!!!!!
ST:20050701 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!!
第二个文件内容是:
ST:20050702 000011 TI:20050719 000011 CN:06 LT:10 PN:13099885853 DN:1015902210 AR:D KC:- RS:@!!!!!!!
ST:20050702 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!!
依次类推
我想用JAVA输入文件名,再查出文件里是LT:90的文件,
(就是我输入:20050701
能打印出:ST:20050701 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!! 这一条)
(输入:20050702
能打印出:ST:20050702 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!! 这一条)希望高手能给出源码,谢谢
20050701.txt
20050702.txt
20050703.txt
20050704.txt
20050705.txt
20050706.txt
20050707.txt
第一个文件内容是:
ST:20050701 000011 TI:20050719 000011 CN:06 LT:10 PN:13099885853 DN:1015902210 AR:D KC:- RS:@!!!!!!!
ST:20050701 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!!
第二个文件内容是:
ST:20050702 000011 TI:20050719 000011 CN:06 LT:10 PN:13099885853 DN:1015902210 AR:D KC:- RS:@!!!!!!!
ST:20050702 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!!
依次类推
我想用JAVA输入文件名,再查出文件里是LT:90的文件,
(就是我输入:20050701
能打印出:ST:20050701 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!! 这一条)
(输入:20050702
能打印出:ST:20050702 000011 TI:20050719 000032 CN:06 LT:90 PN:13099885853 DN:1015902210 AR:D KC:* RS:@!!!!!!! 这一条)希望高手能给出源码,谢谢
解决方案 »
- 【哈希码】对hashCode()的疑问。
- 编译可以通过,执行时出错:NoClassDefFoundError,
- static 与null的问题
- JEditorPane的setPage()方法中能用相当路径吗?能用的话,怎么用?
- [高手请进]关于Toolkit.class.wait()和Toolkit.class.notify()的问题.
- 如何用JAVA获得一个文件的图标,包括文件内嵌的图标和系统指定的图标?在linux下是否一样!
- 如何让java的应用程序支持鼠标中键
- 导入awt包,编译提示非法字符。
- 关于JRE的问题,放分啊,快来!!!
- 打印高手请进:如何得到当前正在打印的页数
- 往数据库中插入一行记录的方法
- 判断字符串里面是否喊含有中文的办法?
*程序
*@win98+jdk1.5
*@author:angel421
*/
import java.io.*;
import java.util.*;
public class Test
{
public static void main(String args[])
{
String read="";
String fileName="*";
while(true){
System.out.println("<<<<<<<<<<<<<<<<<<<<<");
System.out.println("Files is under the same dir,please input the filename:");
Scanner get=new Scanner(System.in);
fileName=get.next();
if(fileName.equals("quit"))
{
System.out.println("exit windows");
System.exit(0);
}
System.out.println("your inputed filename is"+fileName);
System.out.println("begin reading file..............");
System.out.println("the file is ::::::");
try{
File file=new File(fileName+".txt");
FileReader fr=new FileReader(file);
BufferedReader br=new BufferedReader(fr);
while((read=br.readLine())!=null)
{
System.out.println(read);
}
System.out.println("::::::::::");
}
catch(FileNotFoundException e)
{
System.out.println("File is not found"+e.getMessage());
}
catch(IOException e)
{
e.toString();
}
}
}
}
剩下的你自己可以扩展啊,