private static void testMyCompressorStream() { Console.WriteLine("******* testMyCompressorStream *******\n"); int[] size3D = { 3, 6, 7 }; // (z,y,x) IMazeGenerator mazeGenerator3d = new MyMaze3dGenerator(); Maze3d maze = (Maze3d)mazeGenerator3d.generate(size3D); // save the maze to a file – compressed using (FileStream fileOutStream = new FileStream(@"D:\1.maze.txt", FileMode.Create)) { using (Stream outStream = new MyCompressorStream(fileOutStream)) { outStream.Write(maze.toByteArray(), 0, maze.toByteArray().Length); outStream.Flush(); } } byte[] mazeBytes; using (FileStream fileInStream = new FileStream(@"D:\1.maze.txt", FileMode.Open)) { using (Stream inStream = new MyCompressorStream(fileInStream)) { mazeBytes = new byte[maze.toByteArray().Length]; inStream.Read(mazeBytes, 0, mazeBytes.Length); } } Maze3d loadedMaze = new Maze3d(mazeBytes); Console.WriteLine("The original maze : "); maze.print(); maze.getStartPosition().print(); maze.getGoalPosition().print(); Console.WriteLine("The decompress maze : "); loadedMaze.print(); loadedMaze.getStartPosition().print(); loadedMaze.getGoalPosition().print(); Console.WriteLine(loadedMaze.Equals(maze)); }