*/public String loadFileCon(String fileName,File file,String type){String fileContent = "",conTemp = "";byte[] fileConfB
}catch(ioException e){
System.out.println("读取文件内容失败!!!");
e.printStackTrace();
return null;
}
}
public static void main(String args[]){
String filePath;
String[] showFileArr;
String[] realFileArr;
String fileContent;
int choose;
//通过用户获得文件路径和文件名
try{
BufferedReader userInput = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Plase zip file path and name !!!");
filePath = userInput.readLine();
File file = new File(filePath);
while (!(file.exists())) {
System.out.println("Plase input right path again: ");
filePath = userInput.readLine();
file = new File(filePath);
}
//显示文件目录,显示选择的文件的内容
//获得真实文件名和显示文件名数组
ZipFileHandle zipFile = new ZipFileHandle(file);
showFileArr = zipFile.getFileNameList("sh",file);
realFileArr = zipFile.getFileNameList("gr",file);
//打印显示文件名数组
int i = 0;
while (i < showFileArr.length){
System.out.println(showFileArr[i]);
i++;
}
//通过用户输入获得需要显示的文件
System.out.println("Plase choose file num!!!");
choose = Integer.parseInt(userInput.readLine());
if ((choose <0)||(choose > showFileArr.length)){
System.out.println("Plase choose file num retry!!!");
choose = Integer.parseInt(userInput.readLine());
}
//获得用户选择的文件的内容
fileContent = zipFile.loadFileCon(realFileArr[choose],file,"Byte");
System.out.println(fileContent);
}catch(Exception e){
System.out.println("测试程序出错!!!");
e.printStackTrace();
}
}
}
--结束END--
本文标题: JAVA输入输出流详解(H)
本文链接: https://www.lsjlt.com/news/233227.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0