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 the matrix.
              String line = br.readLine();
              String[] rowCol = line.split("\\s+");
              int numRows = Integer.parseInt(rowCol[0]);
              int numCols = Integer.parseInt(rowCol[1]);
  
              // Write out the header for the matrix.
              writer.printf("%d %d\n", numRows, numCols);
  
              // Traverse each row.
              for (int row = 0; (line = br.readLine()) != null && 
                                row < numRows; ++row) {
                  // Traverse each entry in the matrix and transform the value for
                  // the new matrix.
                  String[] values = line.split("\\s+");
                  StringBuilder sb = new StringBuilder(values.length * 4);
                  for (int col = 0; col < numCols; ++col) {
                      double value = Double.parseDouble(values[col]);
                      sb.append(transform.transform(row, col, value)).append(" ");
                  }
                  writer.println(sb.toString());
              }
  
              writer.close();
          } catch (IOException ioe) {
              throw new IOError(ioe);
          }
  
          return outFile;
      }
docs: {@inheritDoc}