Created
August 29, 2017 08:08
-
-
Save ihopeudie/671cea099c41998fe0db3d9ae4f486ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.task.task18.task1805; | |
import java.io.BufferedReader; | |
import java.io.FileInputStream; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.LinkedHashSet; | |
/* | |
Сортировка байт javarush | |
Ввести с консоли имя файла. | |
Считать все байты из файла. | |
Не учитывая повторений — отсортировать их по байт-коду в возрастающем порядке. | |
Вывести на экран. | |
Закрыть поток ввода-вывода. | |
*/ | |
public class Solution { | |
public static void main(String[] args) throws Exception { | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
String fName = reader.readLine(); | |
reader.close(); | |
ArrayList<Integer> list = new ArrayList<>(); | |
FileInputStream iStream = new FileInputStream(fName); | |
while (iStream.available() > 0) { | |
list.add(iStream.read()); | |
} | |
iStream.close(); | |
Collections.sort(list); | |
LinkedHashSet<Integer> list2 = new LinkedHashSet<>(); | |
for (int element: list | |
) { | |
list2.add(element); | |
} | |
for (int element: list2 | |
) { | |
System.out.print(element+" "); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment