Now I directly convert the WWW varible to byte. But it has some problem. Firstly I want to convert the WWW to FileStream and then convert to byte. How to convert WWW type to FileStream? Thank you very much.
My code below:
int i, j, n, m = 0, nFileSize;
byte abybuf = null;
char abybufChar = null;
FileStream stFile = null;
string path;
if (flagPlatform == androidPlatform)
{
WWW www = new WWW("jar:file://" + Application.dataPath + "!/assets/help_text.dat");
abybuf = new byte[www.bytes.Length];
abybuf = www.bytes;
short[] nHelpPos = { 9, 6, 9, 9, 7, 4, 7, 8,
6, 6, 9, 6, 7, 7, 9, 8, 8, 7,
4, 9, 4, 9, 9, 9, 9, 6, 7 };
n = 0;
for (i = 0; i < m_stHelpList.Length; i++)
{
m_stHelpList = new string[nHelpPos];
for (j = 0; j < nHelpPos; j++)
{
nFileSize = (abybuf[n+=1] & 0xFF);
m_stHelpList[j] = System.Text.Encoding.GetEncoding("utf-8").GetString(abybuf, n, nFileSize);
n += nFileSize;
}
}
}
else
{
{
path = Application.dataPath + "/StreamingAssets/help_text.dat";
}
stFile = new FileStream(path, FileMode.Open, FileAccess.Read);
abybuf = new byte[(stFile.ReadByte() & 0xFF) | ((stFile.ReadByte() & 0xFF) << 8)];
stFile.Read(abybuf, 0, abybuf.Length);
short[] nHelpPos = { 9, 6, 9, 9, 7, 4, 7, 8,
6, 6, 9, 6, 7, 7, 9, 8, 8, 7,
4, 9, 4, 9, 9, 9, 9, 6, 7 };
n = 0;
for (i = 0; i < m_stHelpList.Length; i++)
{
m_stHelpList = new string[nHelpPos];
for (j = 0; j < nHelpPos; j++)
{
nFileSize = (abybuf[n++] & 0xFF);
m_stHelpList[j] = System.Text.Encoding.GetEncoding("utf-8").GetString(abybuf, n, nFileSize);
n += nFileSize;
}
}
}