4. In $\triangle A B C$, $A B$ $=B C=12, \angle B=90^{\circ}$, as shown in the figure. Fold along $E F$ so that $A$ coincides with a point $D$ on $B C$. If $B D: D C=2: 1$, then the length of $A E$ is $\qquad$
$$
\begin{array}{l}
\text { 4. } 8 \frac{2}{3} . \\
\because B D \cdot D C=2: 1, \\
\therefore B D=8 .
\end{array}
$$

Let $A E=x$, then $E D=A E=x, B E=12-x$. In Rt $\triangle B D E$, $x^{2}=(12-x)^{2}+8^{2}$. Solving for $x$ yields $x=8 \frac{2}{3}$.