Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. class BufferFile : File
  2. {
  3.  
  4. byte[] buffer;
  5. int index = 0;
  6. BufferFile(String name, int N) : base(name)
  7. {
  8. buffer = new byte[N];
  9. }
  10.  
  11. public override void write(byte b) //Zapisuje jeden byte do buffer'a
  12. {
  13. buffer[index++] = b;
  14. if (index == buffer.Length) writeBuffer();
  15. }
  16.  
  17.  
  18. public void writeBuffer() //Zapisuje cały buffer do pliku
  19. {
  20. for(int n = 0; n < index; n++) //Zapisz tylko od początku do index - 1
  21. {
  22. write(buffer[n]);
  23. }
  24. index = 0;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement