For some reason I am displaying the indices instead of the literal number. I attempted to save the numbers in a set and then convert to a list and sort. please help. Thanks
package com.codegym.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.HashSet;
import java.util.TreeSet;
/*
Sorting bytes
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
HashSet<Integer> intSet = new HashSet<Integer>();
String fileName = reader.readLine();
FileInputStream inStream = new FileInputStream(fileName);
while (inStream.available() > 0){
int data = inStream.read();
intSet.add(data);
//System.out.println(intSet);
}
inStream.close();
reader.close();
//System.out.println(intSet);
ArrayList<Integer> list = new ArrayList<Integer>(intSet);
Collections.sort(list);
for (Integer element : list){
System.out.print(list.get(element)+" ");
}
}
}