public ProblemInstance readInstance(File instanceFile) {

        if(instanceFile == null){
            throw new IllegalArgumentException("Parameter instanceFile null");
        }

        long adInventorySize = 0;
        boolean adOptionParseError = false;
        ArrayList<Item> items = new ArrayList();

        FileInputStream fstream = null;
        DataInputStream in = null;
        try {

            fstream = new FileInputStream(instanceFile);
            in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));

            adInventorySize = this.parseAdInventory(br.readLine());

            String strLine;
            while ((strLine = br.readLine()) != null) {
                Item parsedItem = this.parseAdOptions(strLine);
                if (parsedItem != null) {
                    items.add(parsedItem);
                } else {
                    adOptionParseError = true;
                    break;
                }
            }
        } catch (IOException e) {
            System.err.println("Error during parsing input file: " + e.getMessage());
        } finally {
            safeClose(in);
            safeClose(fstream);
        }

        ProblemInstance problemInstance = null;
        if (adInventorySize != 0 && items.size() > 0 && !adOptionParseError) {
            problemInstance = new ProblemInstance(items, adInventorySize);
        } 
        
        return problemInstance;
    }