java读取文件夹下txt文件中特定信息(很急求解!!!) 250
现在一个文件夹在E盘下,路径为"E:\\七年级",七年级文件夹下有"n.txt,n[1].txt,n[2].txt,n[3].txt......"以此类推到n[100]....
现在一个文件夹在E盘下,路径为"E:\\七年级",七年级文件夹下有"n.txt,n[1].txt,n[2].txt,n[3].txt......"以此类推到n[100].txt。每个txt文件中都包含了json格式的学生基本信息,如打开n.txt中信息如下:[{"sex":"0","date_created":"9/1/2017","city":"合肥","id":"1","url":"","email":"","true_name":"张三","telephone":"13000000000 "},{"sex":"1","date_created":"9/1/2017","city":"合肥","id":"2","url":"","email":"","true_name":"韩梅梅","telephone":"15111111111"},...],每个txt文件都包含类似这样的json学生信息。如何用java程序读取该文件夹中所有txt文件,并且将每个文件中学生的true_name和telephone提取出来,最终效果如下:
张三:13000000000
韩梅梅:15111111111
.
.
.
依次类推。 展开
张三:13000000000
韩梅梅:15111111111
.
.
.
依次类推。 展开
2个回答
2017-09-14
展开全部
java读取文件夹下txt文件中特定信息
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.<a href="https://www.baidu.com/s?wd=Sc&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBPWmLrj7BmhFbnHf3uWc10ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHm1n1mvPH01" target="_blank" class="baidu-highlight">Sc</a>anner;
public class TestRead {
public static void main(String[] args) throws IOException {
String uri = "d:\123.txt"
FileInputStream fis = new FileInputStream(uri);
InputStreamReader isr =new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String s;
while((s=br.readLine())!=null){
//每次读取一行
}
}
}
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.<a href="https://www.baidu.com/s?wd=Sc&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBPWmLrj7BmhFbnHf3uWc10ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHm1n1mvPH01" target="_blank" class="baidu-highlight">Sc</a>anner;
public class TestRead {
public static void main(String[] args) throws IOException {
String uri = "d:\123.txt"
FileInputStream fis = new FileInputStream(uri);
InputStreamReader isr =new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String s;
while((s=br.readLine())!=null){
//每次读取一行
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-09-14
展开全部
现在一个文件夹在E盘下,路径为"E:\\七年级",七年级文件夹下有"n.txt,n[1].txt,n[2].txt,n[3].txt"以此类推到n[100].txt。每个txt文件中都包含了json格式的学生基本信息,如打开n.txt中信息如下:[{"sex":"0","date_created":"9/1/2017","city":"合肥"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询