code: public File transform(File inputFile,
                            File outFile,
                            GlobalTransform transform) {
          try {
              BufferedReader br = new BufferedReader(new FileReader(inputFile));
              PrintWriter writer = new PrintWriter(new BufferedWriter(
                          new FileWriter(outFile)));
  
              // Read in the header for matrix file.
              String line = br.readLine();
              String[] rowColNonZeroCount = line.split("\\s+");
              int numRows = Integer.parseInt(rowColNonZeroCount[0]);
              int numCols = Integer.parseInt(rowColNonZeroCount[1]);
              int numTotalNonZeros = Integer.parseInt(rowColNonZeroCount[2]);
  
              // Write out the header for the new matrix file.
              writer.printf("%d %d %d\n", numRows, numCols, numTotalNonZeros);
  
              line = br.readLine();
              // Traverse each column in the matrix.
              for (int col = 0; line != null && col < numCols; ++col) {
                  int numNonZeros = Integer.parseInt(line);
                  writer.printf("%d\n", numNonZeros);
  
                  // Transform each of the non zero values for the new matrix
                  // file.
                  for (int index = 0; (line = br.readLine()) != null &&
                                      index < numNonZeros; ++index) {
                      String[] rowValue = line.split("\\s+");
                      int row = Integer.parseInt(rowValue[0]);
                      double value = Double.parseDouble(rowValue[1]);
                      writer.printf("%d %f\n", row,
                                    transform.transform(row, col, value));
                  }
              }
  
              writer.close();
          } catch (IOException ioe) {
              throw new IOError(ioe);
          }
  
          return outFile;
      }
docs: {@inheritDoc}