A New Technique for the Determination of the Critical Current Density in Superconducting Films and Flat Samples