读取任意行数据

看的一个前辈的!谢谢

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;

public class ReadJsonLastLine {
	
	public static void main(String[] args) throws IOException {
		
		File file = new File("D://0820--Study//轨迹点数据//pts6.json");
		
		InputStream inputStream = new FileInputStream(file);
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
		
		String strline = readAnyLine(2, bufferedReader);
		System.out.println(strline);
		bufferedReader.close();
		inputStream.close();
	} 
	
	
	public static String readAnyLine(int lineNumber,BufferedReader bufferedReader) throws IOException{
		
		String line ="";
		int i = 0;
		while(i < lineNumber){
			line = bufferedReader.readLine();
			i++;
		}
		return line;
	}

}


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZH519080/article/details/51555851
文章标签: java
个人分类: java
上一篇json解析
下一篇mongodb json
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭