I have the following code:
LZW lzw = new LZW();
int[] a = lzw.Encode(imageBytes);
FileStream fs = new FileStream("image-text-16.txt", FileMode.Append);
BinaryWriter w = new BinaryWriter(fs);
for (int i = 0; i < a.Length; i++)
{
w.Write(a[i]);
}
w.Close();
fs.Close();
How to read array elements from the file? I tried several ways. For example, I wrote the length of the array to the file, and I tried to read the number. However, I had failed.
Note. I need to get the int array.
Are you looking for this:
Or more something like:
Or, a small example with unit tests:
Create a binary file with integers…
And a small example test of reading from a binary file
Another approach of reading from binary file