The relationship between the centroid energies of the isovector giant dipole resonance of finite nuclei and the symmetry energy has been studied. It is found the excitation energies of the dipole resonance in finite nuclei are correlated linearly with the symmetry energy at and below the saturation density. This linear correlation leads to the symmetry energy at the saturation density at the interval 33.0 MeV ≤ S(ρ0) ≤ 37.0 MeV,and the symmetry energy at ρ = 0.1 fm-3 at the interval 21.2-22.5 MeV. It is proposed that a precise measurement of the dipole mode in nuclei could set up an important constraint on the equation of state for nuclear matter.