「とおり」と「ように」の違いは何ですか


I have a question about the difference between とおり and ように.

> 先生が言った **ように** 、試験は難しかった  
>  先生が言った **とおり** 、試験は難しかった




According to "A Dictionary of Intermediate Japanese Grammar", page 517:  
In some contexts, ように, the adverb form of ようだ, also expresses the idea "in
such a way"(just like とおり).  
However, Xように basically means that the way someone does something or something
takes place is like X, while Xとおり means that the way someone does something or
something takes place is the same as X.  
Thus, in contexts where the way is practically the same as X, ように and とおり are
almost interchangeable.

So:  
先生が言ったように: like the teacher said  
先生が言ったとおり: exactly as the teacher said




The difference is small, but ～ように is more akin to "like ～", while ～とおり is "as
～". In your example sentences, the difference may be too subtle. But basically
using ～ように allows a small difference from the original, while ～とおり implies
something is done exactly in the same way.

For example, 彼が言ったように言う sounds like "to speak/talk like him", while
彼が言ったとおりに言う sounds like you reproduce what he said, word by word.

