Validating and reading a Word file in Android

前端 未结 6 1793
忘了有多久
忘了有多久 2020-12-05 16:19

I want to be able to access a word file in the sdcard of the user\'s phone, and the file will be chosen by the user. I want to be able to process the file, i.e. read its con

6条回答
  •  孤城傲影
    2020-12-05 16:43

    I am not sure but what I understand is that what you want is to be able to be sure a file is a word document without simply looking at the extension.

    I think word documents have a file signature (see this link)

    The file signature is in that case a OLE Compound File format having the following binary in header position

    d0 cf 11 e0 a1 b1 1a e1

    So checking the corresponding bytes should say if it is a word document or not. Be careful, I am not sure if the binary is specific for word, doc or docx or available to all microsoft office : powerpoint, excel, word.

    You should perhaps search around the web for "microsoft word document file signature". This will certainly give you the information you are looking for.

    Now, how to "edit" it is another question.

提交回复
热议问题