PageRenderTime 44ms CodeModel.GetById 19ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/commons-io/apidocs/org/apache/commons/io/filefilter/MagicNumberFileFilter.html

https://bitbucket.org/arkban/somersault
HTML | 571 lines | 488 code | 59 blank | 24 comment | 0 complexity | 790213123a5fb179b5df33bcdeda8776 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, Apache-2.0
  1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2<!--NewPage-->
  3<HTML>
  4<HEAD>
  5<!-- Generated by javadoc (build 1.6.0_20) on Tue Sep 28 21:40:06 EDT 2010 -->
  6<TITLE>
  7MagicNumberFileFilter (Commons IO 1.5-SNAPSHOT)
  8</TITLE>
  9
 10<META NAME="date" CONTENT="2010-09-28">
 11
 12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
 13
 14<SCRIPT type="text/javascript">
 15function windowTitle()
 16{
 17    if (location.href.indexOf('is-external=true') == -1) {
 18        parent.document.title="MagicNumberFileFilter (Commons IO 1.5-SNAPSHOT)";
 19    }
 20}
 21</SCRIPT>
 22<NOSCRIPT>
 23</NOSCRIPT>
 24
 25</HEAD>
 26
 27<BODY BGCOLOR="white" onload="windowTitle();">
 28<HR>
 29
 30
 31<!-- ========= START OF TOP NAVBAR ======= -->
 32<A NAME="navbar_top"><!-- --></A>
 33<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
 34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
 35<TR>
 36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
 37<A NAME="navbar_top_firstrow"><!-- --></A>
 38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
 39  <TR ALIGN="center" VALIGN="top">
 40  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
 41  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
 42  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
 43  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
 44  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
 45  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
 46  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
 47  </TR>
 48</TABLE>
 49</TD>
 50<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
 51</EM>
 52</TD>
 53</TR>
 54
 55<TR>
 56<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
 57&nbsp;<A HREF="../../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter"><B>PREV CLASS</B></A>&nbsp;
 58&nbsp;<A HREF="../../../../../org/apache/commons/io/filefilter/NameFileFilter.html" title="class in org.apache.commons.io.filefilter"><B>NEXT CLASS</B></A></FONT></TD>
 59<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
 60  <A HREF="../../../../../index.html?org/apache/commons/io/filefilter/MagicNumberFileFilter.html" target="_top"><B>FRAMES</B></A>  &nbsp;
 61&nbsp;<A HREF="MagicNumberFileFilter.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
 62&nbsp;<SCRIPT type="text/javascript">
 63  <!--
 64  if(window==top) {
 65    document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
 66  }
 67  //-->
 68</SCRIPT>
 69<NOSCRIPT>
 70  <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
 71</NOSCRIPT>
 72
 73
 74</FONT></TD>
 75</TR>
 76<TR>
 77<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
 78  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
 79<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
 80DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
 81</TR>
 82</TABLE>
 83<A NAME="skip-navbar_top"></A>
 84<!-- ========= END OF TOP NAVBAR ========= -->
 85
 86<HR>
 87<!-- ======== START OF CLASS DATA ======== -->
 88<H2>
 89<FONT SIZE="-1">
 90org.apache.commons.io.filefilter</FONT>
 91<BR>
 92Class MagicNumberFileFilter</H2>
 93<PRE>
 94<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
 95  <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html" title="class in org.apache.commons.io.filefilter">org.apache.commons.io.filefilter.AbstractFileFilter</A>
 96      <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.commons.io.filefilter.MagicNumberFileFilter</B>
 97</PRE>
 98<DL>
 99<DT><B>All Implemented Interfaces:</B> <DD><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileFilter.html?is-external=true" title="class or interface in java.io">FileFilter</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/FilenameFilter.html?is-external=true" title="class or interface in java.io">FilenameFilter</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</A>, <A HREF="../../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter">IOFileFilter</A></DD>
100</DL>
101<HR>
102<DL>
103<DT><PRE>public class <B>MagicNumberFileFilter</B><DT>extends <A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html" title="class in org.apache.commons.io.filefilter">AbstractFileFilter</A><DT>implements <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</A></DL>
104</PRE>
105
106<P>
107<p>
108 File filter for matching files containing a "magic number". A magic number 
109 is a unique series of bytes common to all files of a specific file format.
110 For instance, all Java class files begin with the bytes 
111 <code>0xCAFEBABE</code>. 
112 </p>
113 
114 <code><pre>
115 File dir = new File(".");
116 MagicNumberFileFilter javaClassFileFilter =
117     MagicNumberFileFilter(new byte[] {(byte) 0xCA, (byte) 0xFE, 
118       (byte) 0xBA, (byte) 0xBE}); 
119 String[] javaClassFiles = dir.list(javaClassFileFilter);
120 for (String javaClassFile : javaClassFiles) {
121     System.out.println(javaClassFile);
122 }
123 </pre></code>
124 
125 <p>
126 Sometimes, such as in the case of TAR files, the
127 magic number will be offset by a certain number of bytes in the file. In the
128 case of TAR archive files, this offset is 257 bytes.
129 </p>
130 
131 <code><pre>
132 File dir = new File(".");
133 MagicNumberFileFilter tarFileFilter = 
134     MagicNumberFileFilter("ustar", 257); 
135 String[] tarFiles = dir.list(tarFileFilter);
136 for (String tarFile : tarFiles) {
137     System.out.println(tarFile);
138 }
139 </pre></code>
140<P>
141
142<P>
143<DL>
144<DT><B>See Also:</B><DD><A HREF="../../../../../serialized-form.html#org.apache.commons.io.filefilter.MagicNumberFileFilter">Serialized Form</A></DL>
145<HR>
146
147<P>
148<!-- =========== FIELD SUMMARY =========== -->
149
150<A NAME="field_summary"><!-- --></A>
151<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
152<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
153<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
154<B>Field Summary</B></FONT></TH>
155</TR>
156<TR BGCOLOR="white" CLASS="TableRowColor">
157<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
158<CODE>private &nbsp;long</CODE></FONT></TD>
159<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#byteOffset">byteOffset</A></B></CODE>
160
161<BR>
162&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The offset (in bytes) within the files that the magic number's bytes 
163 should appear.</TD>
164</TR>
165<TR BGCOLOR="white" CLASS="TableRowColor">
166<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
167<CODE>private &nbsp;byte[]</CODE></FONT></TD>
168<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#magicNumbers">magicNumbers</A></B></CODE>
169
170<BR>
171&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The magic number to compare against the file's bytes at the provided 
172 offset.</TD>
173</TR>
174<TR BGCOLOR="white" CLASS="TableRowColor">
175<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
176<CODE>private static&nbsp;long</CODE></FONT></TD>
177<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#serialVersionUID">serialVersionUID</A></B></CODE>
178
179<BR>
180&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The serialization version unique identifier.</TD>
181</TR>
182</TABLE>
183&nbsp;
184<!-- ======== CONSTRUCTOR SUMMARY ======== -->
185
186<A NAME="constructor_summary"><!-- --></A>
187<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
188<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
189<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
190<B>Constructor Summary</B></FONT></TH>
191</TR>
192<TR BGCOLOR="white" CLASS="TableRowColor">
193<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#MagicNumberFileFilter(byte[])">MagicNumberFileFilter</A></B>(byte[]&nbsp;magicNumber)</CODE>
194
195<BR>
196&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
197 Constructs a new MagicNumberFileFilter and associates it with the magic
198 number to test for in files.</TD>
199</TR>
200<TR BGCOLOR="white" CLASS="TableRowColor">
201<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#MagicNumberFileFilter(byte[], long)">MagicNumberFileFilter</A></B>(byte[]&nbsp;magicNumber,
202                      long&nbsp;offset)</CODE>
203
204<BR>
205&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
206 Constructs a new MagicNumberFileFilter and associates it with the magic
207 number to test for in files and the byte offset location in the file to
208 to look for that magic number.</TD>
209</TR>
210<TR BGCOLOR="white" CLASS="TableRowColor">
211<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#MagicNumberFileFilter(java.lang.String)">MagicNumberFileFilter</A></B>(<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;magicNumber)</CODE>
212
213<BR>
214&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
215 Constructs a new MagicNumberFileFilter and associates it with the magic
216 number to test for in files.</TD>
217</TR>
218<TR BGCOLOR="white" CLASS="TableRowColor">
219<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#MagicNumberFileFilter(java.lang.String, long)">MagicNumberFileFilter</A></B>(<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;magicNumber,
220                      long&nbsp;offset)</CODE>
221
222<BR>
223&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
224 Constructs a new MagicNumberFileFilter and associates it with the magic
225 number to test for in files and the byte offset location in the file to
226 to look for that magic number.</TD>
227</TR>
228</TABLE>
229&nbsp;
230<!-- ========== METHOD SUMMARY =========== -->
231
232<A NAME="method_summary"><!-- --></A>
233<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
234<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
235<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
236<B>Method Summary</B></FONT></TH>
237</TR>
238<TR BGCOLOR="white" CLASS="TableRowColor">
239<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
240<CODE>&nbsp;boolean</CODE></FONT></TD>
241<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#accept(java.io.File)">accept</A></B>(<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A>&nbsp;file)</CODE>
242
243<BR>
244&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
245 Accepts the provided file if the file contains the file filter's magic
246 number at the specified offset.</TD>
247</TR>
248<TR BGCOLOR="white" CLASS="TableRowColor">
249<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
250<CODE>&nbsp;<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
251<TD><CODE><B><A HREF="../../../../../org/apache/commons/io/filefilter/MagicNumberFileFilter.html#toString()">toString</A></B>()</CODE>
252
253<BR>
254&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a String representation of the file filter, which includes the 
255 magic number bytes and byte offset.</TD>
256</TR>
257</TABLE>
258&nbsp;<A NAME="methods_inherited_from_class_org.apache.commons.io.filefilter.AbstractFileFilter"><!-- --></A>
259<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
260<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
261<TH ALIGN="left"><B>Methods inherited from class org.apache.commons.io.filefilter.<A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html" title="class in org.apache.commons.io.filefilter">AbstractFileFilter</A></B></TH>
262</TR>
263<TR BGCOLOR="white" CLASS="TableRowColor">
264<TD><CODE><A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html#accept(java.io.File, java.lang.String)">accept</A></CODE></TD>
265</TR>
266</TABLE>
267&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
268<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
269<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
270<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
271</TR>
272<TR BGCOLOR="white" CLASS="TableRowColor">
273<TD><CODE><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
274</TR>
275</TABLE>
276&nbsp;
277<P>
278
279<!-- ============ FIELD DETAIL =========== -->
280
281<A NAME="field_detail"><!-- --></A>
282<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
283<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
284<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
285<B>Field Detail</B></FONT></TH>
286</TR>
287</TABLE>
288
289<A NAME="serialVersionUID"><!-- --></A><H3>
290serialVersionUID</H3>
291<PRE>
292private static final long <B>serialVersionUID</B></PRE>
293<DL>
294<DD>The serialization version unique identifier.
295<P>
296<DL>
297<DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.commons.io.filefilter.MagicNumberFileFilter.serialVersionUID">Constant Field Values</A></DL>
298</DL>
299<HR>
300
301<A NAME="magicNumbers"><!-- --></A><H3>
302magicNumbers</H3>
303<PRE>
304private final byte[] <B>magicNumbers</B></PRE>
305<DL>
306<DD>The magic number to compare against the file's bytes at the provided 
307 offset.
308<P>
309<DL>
310</DL>
311</DL>
312<HR>
313
314<A NAME="byteOffset"><!-- --></A><H3>
315byteOffset</H3>
316<PRE>
317private final long <B>byteOffset</B></PRE>
318<DL>
319<DD>The offset (in bytes) within the files that the magic number's bytes 
320 should appear.
321<P>
322<DL>
323</DL>
324</DL>
325
326<!-- ========= CONSTRUCTOR DETAIL ======== -->
327
328<A NAME="constructor_detail"><!-- --></A>
329<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
330<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
331<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
332<B>Constructor Detail</B></FONT></TH>
333</TR>
334</TABLE>
335
336<A NAME="MagicNumberFileFilter(byte[])"><!-- --></A><H3>
337MagicNumberFileFilter</H3>
338<PRE>
339public <B>MagicNumberFileFilter</B>(byte[]&nbsp;magicNumber)</PRE>
340<DL>
341<DD><p>
342 Constructs a new MagicNumberFileFilter and associates it with the magic
343 number to test for in files. This constructor assumes a starting offset
344 of <code>0</code>.
345 </p>
346 
347 <p>
348 It is important to note that <em>the array is not cloned</em> and that
349 any changes to the magic number array after construction will affect the
350 behavior of this file filter.
351 </p>
352 
353 <code><pre>
354 MagicNumberFileFilter javaClassFileFilter =
355     MagicNumberFileFilter(new byte[] {(byte) 0xCA, (byte) 0xFE, 
356       (byte) 0xBA, (byte) 0xBE}); 
357 </pre></code>
358<P>
359<DL>
360<DT><B>Parameters:</B><DD><CODE>magicNumber</CODE> - the magic number to look for in the file.
361<DT><B>Throws:</B>
362<DD><CODE><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>magicNumber</code> is 
363         <code>null</code>, or contains no bytes.</DL>
364</DL>
365<HR>
366
367<A NAME="MagicNumberFileFilter(java.lang.String)"><!-- --></A><H3>
368MagicNumberFileFilter</H3>
369<PRE>
370public <B>MagicNumberFileFilter</B>(<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;magicNumber)</PRE>
371<DL>
372<DD><p>
373 Constructs a new MagicNumberFileFilter and associates it with the magic
374 number to test for in files. This constructor assumes a starting offset
375 of <code>0</code>.
376 </p>
377 
378 Example usage:
379 <pre>
380 <code>MagicNumberFileFilter xmlFileFilter = 
381     MagicNumberFileFilter("&lt;?xml"); 
382 </code>
383 </pre>
384<P>
385<DL>
386<DT><B>Parameters:</B><DD><CODE>magicNumber</CODE> - the magic number to look for in the file.
387        The string is converted to bytes using the platform default charset.
388<DT><B>Throws:</B>
389<DD><CODE><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>magicNumber</code> is 
390         <code>null</code> or the empty String.</DL>
391</DL>
392<HR>
393
394<A NAME="MagicNumberFileFilter(java.lang.String, long)"><!-- --></A><H3>
395MagicNumberFileFilter</H3>
396<PRE>
397public <B>MagicNumberFileFilter</B>(<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>&nbsp;magicNumber,
398                             long&nbsp;offset)</PRE>
399<DL>
400<DD><p>
401 Constructs a new MagicNumberFileFilter and associates it with the magic
402 number to test for in files and the byte offset location in the file to
403 to look for that magic number.
404 </p>
405 
406 <code><pre>
407 MagicNumberFileFilter tarFileFilter = 
408     MagicNumberFileFilter("ustar", 257); 
409 </pre></code>
410<P>
411<DL>
412<DT><B>Parameters:</B><DD><CODE>magicNumber</CODE> - the magic number to look for in the file. 
413        The string is converted to bytes using the platform default charset.<DD><CODE>offset</CODE> - the byte offset in the file to start comparing bytes.
414<DT><B>Throws:</B>
415<DD><CODE><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>magicNumber</code> is 
416         <code>null</code> or the empty String, or <code>offset</code> is 
417         a negative number.</DL>
418</DL>
419<HR>
420
421<A NAME="MagicNumberFileFilter(byte[], long)"><!-- --></A><H3>
422MagicNumberFileFilter</H3>
423<PRE>
424public <B>MagicNumberFileFilter</B>(byte[]&nbsp;magicNumber,
425                             long&nbsp;offset)</PRE>
426<DL>
427<DD><p>
428 Constructs a new MagicNumberFileFilter and associates it with the magic
429 number to test for in files and the byte offset location in the file to
430 to look for that magic number.
431 </p>
432 
433 <p>
434 It is important to note that <em>the array is not cloned</em> and that
435 any changes to the magic number array after construction will affect the
436 behavior of this file filter.
437 </p>
438 
439 <code><pre>
440 MagicNumberFileFilter tarFileFilter =
441     MagicNumberFileFilter(new byte[] {0x75, 0x73, 0x74, 0x61, 0x72}, 257); 
442 </pre></code>
443 
444 <code><pre>
445 MagicNumberFileFilter javaClassFileFilter =
446     MagicNumberFileFilter(new byte[] {0xCA, 0xFE, 0xBA, 0xBE}, 0); 
447 </pre></code>
448<P>
449<DL>
450<DT><B>Parameters:</B><DD><CODE>magicNumber</CODE> - the magic number to look for in the file.<DD><CODE>offset</CODE> - the byte offset in the file to start comparing bytes.
451<DT><B>Throws:</B>
452<DD><CODE><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>magicNumber</code> is 
453         <code>null</code>, or contains no bytes, or <code>offset</code> 
454         is a negative number.</DL>
455</DL>
456
457<!-- ============ METHOD DETAIL ========== -->
458
459<A NAME="method_detail"><!-- --></A>
460<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
461<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
462<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
463<B>Method Detail</B></FONT></TH>
464</TR>
465</TABLE>
466
467<A NAME="accept(java.io.File)"><!-- --></A><H3>
468accept</H3>
469<PRE>
470public boolean <B>accept</B>(<A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A>&nbsp;file)</PRE>
471<DL>
472<DD><p>
473 Accepts the provided file if the file contains the file filter's magic
474 number at the specified offset.
475 </p>
476 
477 <p>
478 If any <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io"><CODE>IOException</CODE></A>s occur while reading the file, the file will
479 be rejected.
480 </p>
481<P>
482<DD><DL>
483<DT><B>Specified by:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileFilter.html?is-external=true#accept(java.io.File)" title="class or interface in java.io">accept</A></CODE> in interface <CODE><A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileFilter.html?is-external=true" title="class or interface in java.io">FileFilter</A></CODE><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../org/apache/commons/io/filefilter/IOFileFilter.html#accept(java.io.File)">accept</A></CODE> in interface <CODE><A HREF="../../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter">IOFileFilter</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html#accept(java.io.File)">accept</A></CODE> in class <CODE><A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html" title="class in org.apache.commons.io.filefilter">AbstractFileFilter</A></CODE></DL>
484</DD>
485<DD><DL>
486<DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to accept or reject.
487<DT><B>Returns:</B><DD><code>true</code> if the file contains the filter's magic number 
488         at the specified offset, <code>false</code> otherwise.</DL>
489</DD>
490</DL>
491<HR>
492
493<A NAME="toString()"><!-- --></A><H3>
494toString</H3>
495<PRE>
496public <A HREF="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>toString</B>()</PRE>
497<DL>
498<DD>Returns a String representation of the file filter, which includes the 
499 magic number bytes and byte offset.
500<P>
501<DD><DL>
502<DT><B>Overrides:</B><DD><CODE><A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../../../../org/apache/commons/io/filefilter/AbstractFileFilter.html" title="class in org.apache.commons.io.filefilter">AbstractFileFilter</A></CODE></DL>
503</DD>
504<DD><DL>
505
506<DT><B>Returns:</B><DD>a String representation of the file filter.</DL>
507</DD>
508</DL>
509<!-- ========= END OF CLASS DATA ========= -->
510<HR>
511
512
513<!-- ======= START OF BOTTOM NAVBAR ====== -->
514<A NAME="navbar_bottom"><!-- --></A>
515<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
516<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
517<TR>
518<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
519<A NAME="navbar_bottom_firstrow"><!-- --></A>
520<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
521  <TR ALIGN="center" VALIGN="top">
522  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
523  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
524  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
525  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
526  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
527  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
528  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
529  </TR>
530</TABLE>
531</TD>
532<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
533</EM>
534</TD>
535</TR>
536
537<TR>
538<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
539&nbsp;<A HREF="../../../../../org/apache/commons/io/filefilter/IOFileFilter.html" title="interface in org.apache.commons.io.filefilter"><B>PREV CLASS</B></A>&nbsp;
540&nbsp;<A HREF="../../../../../org/apache/commons/io/filefilter/NameFileFilter.html" title="class in org.apache.commons.io.filefilter"><B>NEXT CLASS</B></A></FONT></TD>
541<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
542  <A HREF="../../../../../index.html?org/apache/commons/io/filefilter/MagicNumberFileFilter.html" target="_top"><B>FRAMES</B></A>  &nbsp;
543&nbsp;<A HREF="MagicNumberFileFilter.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
544&nbsp;<SCRIPT type="text/javascript">
545  <!--
546  if(window==top) {
547    document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
548  }
549  //-->
550</SCRIPT>
551<NOSCRIPT>
552  <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
553</NOSCRIPT>
554
555
556</FONT></TD>
557</TR>
558<TR>
559<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
560  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
561<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
562DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
563</TR>
564</TABLE>
565<A NAME="skip-navbar_bottom"></A>
566<!-- ======== END OF BOTTOM NAVBAR ======= -->
567
568<HR>
569Copyright (c) 2002-2010  Apache Software Foundation
570</BODY>
571</HTML>