The correct form for reading is in most cases:
Ich habe in dem Buch (Dat) gelesen.
I read in the book.
Ich habe in dem Buch (Dat) viele Beispiele (Akk) gelesen.
I read many examples in the book.
You can use the accusative with a different verb (hineinlesen), but it changes the meaning from just reading to speculation, and needs a an additional accusative object to indicate what the result of that interpretation.
Ich habe etwas (Akk) in das Buch (Akk) hineingelesen.
I read something in the book and interpreted it in a certain way.
You always use accusative for both what you write and where you write it.
Ich habe meine Probleme (Akk) in den Brief (Akk) geschrieben.
But if you combine this with "über", it changes:
Ich habe über meine Probleme (Akk) in dem Brief (Dat) geschrieben.
which I'd normally change to
Ich habe in dem Brief (Dat) über meine Probleme (Akk) geschrieben.
because it sounds more natural to me. The first form might also be misunderstood as if you were writing (somewhere, not specified) about any problems (maybe delivery? maybe writing?) you had with the letter. You'd probably better use "Probleme mit dem Brief" if you actually mean the later, though.
You also use dative to indicate e.g., the means of writing:
Ich habe mit dem Bleistift (Dat) geschrieben.