public class Solution {
public static void main(String[] args) throws IOException {
int id = Integer.parseInt(args[0]);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = reader.readLine();
FileInputStream fileInputStream = new FileInputStream(fileName);
byte [] readedByte = new byte[fileInputStream.available()];
fileInputStream.read(readedByte);
String st = new String(readedByte);
String [] priceList = st.split(" ");
for(int i = 0; i<priceList.length; i=i+4){
if(Integer.parseInt(priceList[i])==id){
System.out.print(priceList[i]+ " ");
System.out.print(priceList[i+1] + " ");
System.out.print(priceList[i+2] + " ");
System.out.print(priceList[i+3] + " ");
}
}
fileInputStream.close();
reader.close();
}
}
package com.javarush.task.task18.task1822;
/*
Поиск данных внутри файла
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws IOException {
int id = Integer.parseInt(args[0]);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = reader.readLine();
FileInputStream fileInputStream = new FileInputStream(fileName);
byte [] readedByte = new byte[fileInputStream.available()];
fileInputStream.read(readedByte);
String st = new String(readedByte);
String [] priceList = st.split(" ");
for(int i = 0; i<priceList.length; i=i+4){
if(Integer.parseInt(priceList[i])==id){
System.out.print(Integer.parseInt(priceList[i] )+ " ");
System.out.print(priceList[i+1] + " ");
System.out.print(Double.valueOf(priceList[i+2]) + " ");
System.out.print(Integer.parseInt(priceList[i+3]) + " ");
}
}
fileInputStream.close();
reader.close();
}
}