File: BufferingTest.java

package info (click to toggle)
libtritonus-java 20070428-12
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,960 kB
  • ctags: 11,917
  • sloc: ansic: 53,816; java: 45,226; sh: 3,022; makefile: 1,190; xml: 820; cpp: 147
file content (81 lines) | stat: -rw-r--r-- 2,135 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 *	BufferingTest.java
 */

/*
 *  Copyright (c) 1999, 2000 by Matthias Pfisterer <Matthias.Pfisterer@web.de>
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as published
 *   by the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Library General Public License for more details.
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


import	java.io.BufferedInputStream;
import	java.io.ByteArrayInputStream;
import	java.io.FileInputStream;
import	java.io.InputStream;
import	java.io.IOException;



public class BufferingTest
{
	public static void main(String[] args)
		throws IOException
	{
// 		byte[]	abData = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
// 		ByteArrayInputStream	bais = new ByteArrayInputStream(abData);
// 		System.out.println(bais.markSupported());
// 		bais.mark(15);
// 		bais.reset();

		FileInputStream	fis = new FileInputStream("BufferingTest.java");
		System.out.println("FileInputStream supports mark: " + fis.markSupported());

		BufferedInputStream	bis = new BufferedInputStream(fis, 5);
		byte[]	abRead1 = new byte[9];
		byte[]	abRead2 = new byte[9];
		byte[]	abRead3 = new byte[9];
		byte[]	abRead4 = new byte[9];
		bis.mark(9);
		bis.read(abRead1);
		bis.mark(9);
		bis.read(abRead2);
		bis.reset();
		bis.read(abRead3);
		bis.reset();
		bis.read(abRead4);

		for (int i = 0; i < abRead1.length; i++)
		{
			if (abRead1[i] != abRead4[i])
			{
				System.out.println("1 difference!!");
			}
		}
		for (int i = 0; i < abRead1.length; i++)
		{
			if (abRead2[i] != abRead3[i])
			{
				System.out.println("2 difference!!");
			}
		}
	}
}



/*** BufferingTest.java ***/