Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.task.task18.task1822;
- /*
- Поиск данных внутри файла
- */
- import java.io.BufferedReader;
- import java.io.FileInputStream;
- import java.io.FileReader;
- import java.io.InputStreamReader;
- import java.sql.SQLOutput;
- import java.util.ArrayList;
- public class Solution {
- public static void main(String[] args) throws Exception{
- String str;
- BufferedReader readerFile = new BufferedReader(new InputStreamReader(System.in));
- String fileName = readerFile.readLine();
- readerFile.close();
- BufferedReader readerData = new BufferedReader(new FileReader(fileName)); //C:\temp\j\input.txt
- // BufferedReader readerData = new BufferedReader(new FileReader("C:\\temp\\j\\input.txt"));
- // ArrayList<String> list = new ArrayList<String>();
- while ((str = readerData.readLine()) != null) {
- // if (!str.isEmpty()){
- // list.add(str);
- //// System.out.println(str);
- // }
- if (str.contains(args[0] + " ")) System.out.println(str);
- // if (str.startsWith("id " + args[0] + " ")) System.out.println(str);
- }
- readerData.close();
- /*String[] stringArr = list.toArray(new String[0]);
- *//*System.out.println("list");
- for (String st : list) {
- System.out.println(st);
- }*//*
- *//*System.out.println("array");
- for (String st : stringArr) {
- System.out.println(st);
- }*//*
- //проверяем строки на включение нужного нам ID
- // String id = "id " + args[0];
- // System.out.println(id);
- for (String st : list) {
- if (st.contains("id " + args[0])) {
- System.out.println(st);
- }
- }*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement