public boolean readPartition(String filename)
    {
        FileInputStream in = null;
        BufferedReader reader = null;

        try
        {
            // Open one partition file as input.
            in = new FileInputStream(filename);
            reader = new BufferedReader(new InputStreamReader(in));

            String line = null;
            // For each line, read features and the target attribute
            while (null != (line = reader.readLine()))
            {

                // For each line, read the first string as the partition id.
                String[] str = line.split(" +");
                // illegal format.
                if (str.length <= 1)
                {
                    System.err.println("Illegal partition file.");
                    return false;
                }

                // read partition id
                Partition partition = new Partition();
                partition.id = str[0];
                // read elements in each partition.
                partition.elements = new ArrayList<Integer>();
                for (int j = 1; j < str.length; j++)
                {
                    partition.elements.add(Integer.parseInt(str[j]));
                }
                partitions.add(partition);
            }
        }
        catch (IOException e)
        {
            System.err.println("Could not open dataset file. ");
            return false;
        }
        catch (NumberFormatException e)
        {
            System.err.println("Illegal arguments in dataset file.");
            return false;
        }
        finally
        {
            // Close file.
            if (null != reader)
            {
                try
                {
                    reader.close();
                }
                catch (IOException e2)
                {
                    System.err.println("error when close partition file.");
                }
            }
            if (null != in)
            {
                try
                {
                    in.close();
                }
                catch (IOException e2)
                {
                    System.err.println("error when close partition file.");
                }
            }
        }
        return true;
    }