Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. package com.javarush.task.task18.task1822;
  2.  
  3. /*
  4. Поиск данных внутри файла
  5. */
  6.  
  7. import java.io.BufferedReader;
  8. import java.io.FileInputStream;
  9. import java.io.FileReader;
  10. import java.io.InputStreamReader;
  11. import java.sql.SQLOutput;
  12. import java.util.ArrayList;
  13.  
  14. public class Solution {
  15. public static void main(String[] args) throws Exception{
  16. String str;
  17. BufferedReader readerFile = new BufferedReader(new InputStreamReader(System.in));
  18. String fileName = readerFile.readLine();
  19. readerFile.close();
  20. BufferedReader readerData = new BufferedReader(new FileReader(fileName)); //C:\temp\j\input.txt
  21.  
  22. // BufferedReader readerData = new BufferedReader(new FileReader("C:\\temp\\j\\input.txt"));
  23. // ArrayList<String> list = new ArrayList<String>();
  24. while ((str = readerData.readLine()) != null) {
  25. // if (!str.isEmpty()){
  26. // list.add(str);
  27. //// System.out.println(str);
  28. // }
  29. if (str.contains(args[0] + " ")) System.out.println(str);
  30. // if (str.startsWith("id " + args[0] + " ")) System.out.println(str);
  31. }
  32.  
  33. readerData.close();
  34.  
  35. /*String[] stringArr = list.toArray(new String[0]);
  36. *//*System.out.println("list");
  37. for (String st : list) {
  38. System.out.println(st);
  39. }*//*
  40. *//*System.out.println("array");
  41. for (String st : stringArr) {
  42. System.out.println(st);
  43. }*//*
  44. //проверяем строки на включение нужного нам ID
  45.  
  46. // String id = "id " + args[0];
  47. // System.out.println(id);
  48. for (String st : list) {
  49. if (st.contains("id " + args[0])) {
  50. System.out.println(st);
  51. }
  52. }*/
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement