资源简介
关于数据查找与提取的java代码,使用者可以通过java 程序进行对txt文件内容的咨询与查找
代码片段和文件信息
/*
* Name: Serge Babayan
* Date: March 4 2014
* Assignment:OOP Assignment Part 1- Reading from a flat file
* Description: Main method that reads from a flat file sorts everything into proper arrays
*/
import java.io.*;
import libraries.*;//importing libraries where student class is located
public class Main{
public static void main(String args[]){
//creating Buffered reader object to read from the flat file
try{
BufferedReader in = new BufferedReader (new FileReader (“student_flat.txt“));
//creating string object to hold a line from the flat file
String line;
//figuring out how many lines the flat file has
int numberOfLines=0;
while((line=in.readLine())!=null){
numberOfLines++;
}
//creating new buffered reader object
BufferedReader in2 = new BufferedReader (new FileReader (“student_flat.txt“));
//creating arrays to hold all different types of info
String studentNumbers[]=new String [numberOfLines]; //no data manipulation necessary so using string
String studentName []=new String [numberOfLines];
String studentAddress[]=new String [numberOfLines];
String studentDateOfBirth[]=new String [numberOfLines];
int studentAge[]=new int [numberOfLines];
int studentGrade[]=new int[numberOfLines];
String studentPhoneNumber[]=new String [numberOfLines];//no data manipulation necessary so using string
boolean literacyTestStatus[]=new boolean[numberOfLines];
String studentFirstLanguage[]=new String[numberOfLines];
int studentCommunityHours[]=new int[numberOfLines];
int studentCreditsAcquired[]=new int[numberOfLines];
double[] studentAverage=new double[numberOfLines];
int currentLineNumber=0; //setting a counter so it only cycles up to the amount of lines there are
//while loop to cycle through each line of the file
while((line=in2.readLine())!=null){
String delimiter=““; //splitting up each line into it‘s different components
String[] temporaryArray=line.split(delimiter); //creating temporary array to hold each part of the line
//sorts components of each line in the proper array
studentNumbers[currentLineNumber]=temporaryArray[0];
studentName[currentLineNumber]= temporaryArray[1];
studentAddress[currentLineNumber]=temporaryArray[2];
studentDateOfBirth[currentLineNumber]=temporaryArray[3];
studentAge[currentLineNumber]=Integer.parseInt(temporaryArray[4]);
studentGrade[currentLineNumber]=Integer.parseInt(temporaryArray[5]);
studentPhoneNumber[currentLineNumber]=temporaryArray[6];
//setting literacy test status
if (temporaryArray[7].equals(“Pass“)){
literacyTestStatus[currentLineNumber]=true;
}
else if (temporaryArray[7].equals(“Fail“)){
literacyTestStatus[currentLineNumber]=false;
}
studentFirstLanguage[currentLineNumber]=temporaryArray[8];
studentCommunityHours[currentLineNumber]=Integer.parseInt(tempor
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 178 2014-03-07 22:25 ICS4U-Assignment 1(Serge Hassan Ryan)\How to use the Documentation.txt
目录 0 2014-03-07 22:26 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 1\
目录 0 2014-03-07 22:19 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 1\libraries\
文件 7372 2014-03-07 22:19 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 1\libraries\Student.java
文件 4299 2014-03-07 13:56 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 1\Main.java
文件 2965 2014-03-07 16:37 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 1\Pseudo code for reading from a file.txt
文件 1042 2014-03-07 13:55 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 1\student_flat.txt
目录 0 2014-03-07 22:26 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 2\
目录 0 2014-03-07 22:26 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 2\libraries\
文件 7976 2014-03-07 22:09 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 2\libraries\Helper.java
文件 7377 2014-03-07 22:09 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 2\libraries\Student.java
文件 4557 2014-03-07 22:09 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 2\Main.java
文件 619 2014-03-07 17:54 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 2\Pseudo code for find method.txt
文件 1040 2014-03-07 22:22 ICS4U-Assignment 1(Serge Hassan Ryan)\Part 2\student_flat.txt
文件 9880 2014-03-07 22:55 ICS4U-Assignment 1(Serge Hassan Ryan)\SoftwareProjectPlan.docx
文件 20694 2014-03-07 22:13 ICS4U-Assignment 1(Serge Hassan Ryan)\Student Info Databa
文件 5722 2014-03-07 22:16 ICS4U-Assignment 1(Serge Hassan Ryan)\UML for Student Class.docx
- 上一篇:校园二手交易
- 下一篇:JAVA绘制简单函数图像工具
相关资源
- JAVA绘制简单函数图像工具
- 字符串相似度比对JAVA
- Java财务管理信息系统
- 操作系统课程设计Java实现
- 基于J2EE的公交查询系统的设计与实现
- 文件上传并读取plupload与java后台的整
- java编写的音像店管理系统
- JavaWeb项目生成验证码
- 余弦相似性获取文章相似度的java实现
- Android应用源码蓝牙串口搜索配对连接
- java elasticsearch rest风格索引操作
- java后台获取小程序用户信息和生成自
- java图论库——JGraphT
- java连接Redis所需jar包
- java批量删除
- 计算下一天的日期
- java SM4加密demo
- java个人简历
- Java秒杀系统方案全套视频.zip
- 《Java程序设计第2版》唐大仕 源代码
- nginx、ffmpeg转流java集成
- Elasticsearch5.5.1 JAVA客户端RestClient
- java反射工具类 ReflectionUtils
- Jpcap资料与应用
- RFID输液管理系统
- Head first java 源码完整版
- 基于java socket编写的超市管理系统
- 仓库管理系统+可视化界面java编写
- 计算机外文文献
- 用java写的查询某市地铁的最短路径,
评论
共有 条评论