1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5 <!-- Generated by javadoc (build 1.5.0_09) on Sun Jul 15 14:27:35 BST 2007 -->
7 File (leJOS NXT API documentation)
10 <META NAME="keywords" CONTENT="java.io.File class">
12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
14 <SCRIPT type="text/javascript">
15 function windowTitle()
17 parent.document.title="File (leJOS NXT API documentation)";
25 <BODY BGCOLOR="white" onload="windowTitle();">
28 <!-- ========= START OF TOP NAVBAR ======= -->
29 <A NAME="navbar_top"><!-- --></A>
30 <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
31 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
33 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
34 <A NAME="navbar_top_firstrow"><!-- --></A>
35 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
36 <TR ALIGN="center" VALIGN="top">
37 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
38 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
39 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
42 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
47 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
53 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
54 <A HREF="../../java/io/DataOutputStream.html" title="class in java.io"><B>PREV CLASS</B></A>
55 <A HREF="../../java/io/FileInputStream.html" title="class in java.io"><B>NEXT CLASS</B></A></FONT></TD>
56 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
57 <A HREF="../../index.html?java/io/File.html" target="_top"><B>FRAMES</B></A>
58 <A HREF="File.html" target="_top"><B>NO FRAMES</B></A>
59 <SCRIPT type="text/javascript">
62 document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
67 <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
74 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
75 SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
76 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
77 DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
80 <A NAME="skip-navbar_top"></A>
81 <!-- ========= END OF TOP NAVBAR ========= -->
84 <!-- ======== START OF CLASS DATA ======== -->
91 <A HREF="../../java/lang/Object.html" title="class in java.lang">java.lang.Object</A>
92 <IMG SRC="../../resources/inherit.gif" ALT="extended by "><B>java.io.File</B>
96 <DT><PRE>public class <B>File</B><DT>extends <A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></DL>
103 <!-- =========== FIELD SUMMARY =========== -->
105 <A NAME="field_summary"><!-- --></A>
106 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
107 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
108 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
109 <B>Field Summary</B></FONT></TH>
111 <TR BGCOLOR="white" CLASS="TableRowColor">
112 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
113 <CODE>protected static short</CODE></FONT></TD>
114 <TD><CODE><B><A HREF="../../java/io/File.html#BYTES_PER_PAGE">BYTES_PER_PAGE</A></B></CODE>
117 Indicates the # of bytes per page in the Flash class.</TD>
119 <TR BGCOLOR="white" CLASS="TableRowColor">
120 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
121 <CODE>static byte</CODE></FONT></TD>
122 <TD><CODE><B><A HREF="../../java/io/File.html#MAX_FILES">MAX_FILES</A></B></CODE>
125 Number of files the file system can store.</TD>
127 <TR BGCOLOR="white" CLASS="TableRowColor">
128 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
129 <CODE>static byte</CODE></FONT></TD>
130 <TD><CODE><B><A HREF="../../java/io/File.html#totalFiles">totalFiles</A></B></CODE>
133 The total number of files in the file system.</TD>
137 <!-- ======== CONSTRUCTOR SUMMARY ======== -->
139 <A NAME="constructor_summary"><!-- --></A>
140 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
141 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
142 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
143 <B>Constructor Summary</B></FONT></TH>
145 <TR BGCOLOR="white" CLASS="TableRowColor">
146 <TD><CODE><B><A HREF="../../java/io/File.html#File(java.lang.String)">File</A></B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A> name)</CODE>
149 Creates a new File object.</TD>
153 <!-- ========== METHOD SUMMARY =========== -->
155 <A NAME="method_summary"><!-- --></A>
156 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
157 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
158 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
159 <B>Method Summary</B></FONT></TH>
161 <TR BGCOLOR="white" CLASS="TableRowColor">
162 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
163 <CODE> boolean</CODE></FONT></TD>
164 <TD><CODE><B><A HREF="../../java/io/File.html#createNewFile()">createNewFile</A></B>()</CODE>
167 Creates a new file entry in the flash memory.</TD>
169 <TR BGCOLOR="white" CLASS="TableRowColor">
170 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
171 <CODE>static void</CODE></FONT></TD>
172 <TD><CODE><B><A HREF="../../java/io/File.html#defrag()">defrag</A></B>()</CODE>
175 assumptions: the files[] array has no nulls, and is in increasing order by page_location
176 this scheme moves moves each file down to fill in the empty pages.</TD>
178 <TR BGCOLOR="white" CLASS="TableRowColor">
179 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
180 <CODE> boolean</CODE></FONT></TD>
181 <TD><CODE><B><A HREF="../../java/io/File.html#delete()">delete</A></B>()</CODE>
184 Deletes the file represented by this File object.</TD>
186 <TR BGCOLOR="white" CLASS="TableRowColor">
187 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
188 <CODE> void</CODE></FONT></TD>
189 <TD><CODE><B><A HREF="../../java/io/File.html#exec()">exec</A></B>()</CODE>
192 If the file is a binary executable, begins running it.</TD>
194 <TR BGCOLOR="white" CLASS="TableRowColor">
195 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
196 <CODE> boolean</CODE></FONT></TD>
197 <TD><CODE><B><A HREF="../../java/io/File.html#exists()">exists</A></B>()</CODE>
200 Indicates if the file exists in the flash memory.</TD>
202 <TR BGCOLOR="white" CLASS="TableRowColor">
203 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
204 <CODE>static void</CODE></FONT></TD>
205 <TD><CODE><B><A HREF="../../java/io/File.html#format()">format</A></B>()</CODE>
208 Essentially formats the file system by writing TABLE_ID characters to
209 the first page of flash memroy.</TD>
211 <TR BGCOLOR="white" CLASS="TableRowColor">
212 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
213 <CODE>static int</CODE></FONT></TD>
214 <TD><CODE><B><A HREF="../../java/io/File.html#freeMemory()">freeMemory</A></B>()</CODE>
217 </TD>
219 <TR BGCOLOR="white" CLASS="TableRowColor">
220 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
221 <CODE> int</CODE></FONT></TD>
222 <TD><CODE><B><A HREF="../../java/io/File.html#getIndex()">getIndex</A></B>()</CODE>
225 returns location of file in the files[] array</TD>
227 <TR BGCOLOR="white" CLASS="TableRowColor">
228 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
229 <CODE> <A HREF="../../java/lang/String.html" title="class in java.lang">String</A></CODE></FONT></TD>
230 <TD><CODE><B><A HREF="../../java/io/File.html#getName()">getName</A></B>()</CODE>
233 Returns the name of the file.</TD>
235 <TR BGCOLOR="white" CLASS="TableRowColor">
236 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
237 <CODE> int</CODE></FONT></TD>
238 <TD><CODE><B><A HREF="../../java/io/File.html#getPage()">getPage</A></B>()</CODE>
241 </TD>
243 <TR BGCOLOR="white" CLASS="TableRowColor">
244 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
245 <CODE> int</CODE></FONT></TD>
246 <TD><CODE><B><A HREF="../../java/io/File.html#length()">length</A></B>()</CODE>
249 Returns the length of the file denoted by this file name.</TD>
251 <TR BGCOLOR="white" CLASS="TableRowColor">
252 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
253 <CODE>static <A HREF="../../java/io/File.html" title="class in java.io">File</A>[]</CODE></FONT></TD>
254 <TD><CODE><B><A HREF="../../java/io/File.html#listFiles()">listFiles</A></B>()</CODE>
257 Returns a list of files in the flash file system.</TD>
259 <TR BGCOLOR="white" CLASS="TableRowColor">
260 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
261 <CODE> void</CODE></FONT></TD>
262 <TD><CODE><B><A HREF="../../java/io/File.html#moveToTop()">moveToTop</A></B>()</CODE>
265 move the file to become the last one in flash memory</TD>
268 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
269 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
270 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
271 <TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html" title="class in java.lang">Object</A></B></TH>
273 <TR BGCOLOR="white" CLASS="TableRowColor">
274 <TD><CODE><A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A></CODE></TD>
280 <!-- ============ FIELD DETAIL =========== -->
282 <A NAME="field_detail"><!-- --></A>
283 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
284 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
285 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
286 <B>Field Detail</B></FONT></TH>
290 <A NAME="MAX_FILES"><!-- --></A><H3>
293 public static final byte <B>MAX_FILES</B></PRE>
295 <DD>Number of files the file system can store.
296 Defines the size of the files array. If leJOS gets a garbage
297 collector we can get rid of this limitation.
300 <DT><B>See Also:</B><DD><A HREF="../../constant-values.html#java.io.File.MAX_FILES">Constant Field Values</A></DL>
304 <A NAME="BYTES_PER_PAGE"><!-- --></A><H3>
307 protected static short <B>BYTES_PER_PAGE</B></PRE>
309 <DD>Indicates the # of bytes per page in the Flash class.
310 Lawrie Griffiths determines this. Might want to access this
311 directly from Flash in future from a package level constant in case
312 we want to alter this number.
319 <A NAME="totalFiles"><!-- --></A><H3>
322 public static byte <B>totalFiles</B></PRE>
324 <DD>The total number of files in the file system. A negative value
325 indicates this variable has not been initialized. Using byte, but
326 if we expand past the 30 limit (garbage collector) we can use short.
332 <!-- ========= CONSTRUCTOR DETAIL ======== -->
334 <A NAME="constructor_detail"><!-- --></A>
335 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
336 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
337 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
338 <B>Constructor Detail</B></FONT></TH>
342 <A NAME="File(java.lang.String)"><!-- --></A><H3>
345 public <B>File</B>(<A HREF="../../java/lang/String.html" title="class in java.lang">String</A> name)</PRE>
347 <DD>Creates a new File object. If this file exists on disk it will
348 represent that file. If the file does not exist, you will need to
349 use createNewFile() before writing to the file.
352 <DT><B>Parameters:</B><DD><CODE>name</CODE> - </DL>
355 <!-- ============ METHOD DETAIL ========== -->
357 <A NAME="method_detail"><!-- --></A>
358 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
359 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
360 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
361 <B>Method Detail</B></FONT></TH>
365 <A NAME="delete()"><!-- --></A><H3>
368 public boolean <B>delete</B>()</PRE>
370 <DD>Deletes the file represented by this File object.
374 <DT><B>Returns:</B><DD>true if the file is successfully deleted; false otherwise</DL>
379 <A NAME="exec()"><!-- --></A><H3>
382 public void <B>exec</B>()</PRE>
384 <DD>If the file is a binary executable, begins running it.
392 <A NAME="listFiles()"><!-- --></A><H3>
395 public static <A HREF="../../java/io/File.html" title="class in java.io">File</A>[] <B>listFiles</B>()</PRE>
397 <DD>Returns a list of files in the flash file system. Because there are no
398 directories, this is a static method in leJOS NXJ. The order of the files
399 in the array goes from oldest (0) to newest (highest index array).
403 <DT><B>Returns:</B><DD>An array of File objects representing files in the file system.
404 The array will be empty if the directory is empty.
406 NOTE: In the Java SDK this method should return an array
407 of size equaling the number of files. However, because leJOS has no garbage
408 collector it returns the same array that is always 30 in length. The unused
409 file spots are null. Use File.totalFiles to determine number of files.</DL>
414 <A NAME="getName()"><!-- --></A><H3>
417 public <A HREF="../../java/lang/String.html" title="class in java.lang">String</A> <B>getName</B>()</PRE>
419 <DD>Returns the name of the file.
423 <DT><B>Returns:</B><DD>The name of the file, including the file extension. e.g. "mapdata.txt"</DL>
428 <A NAME="length()"><!-- --></A><H3>
431 public int <B>length</B>()</PRE>
433 <DD>Returns the length of the file denoted by this file name.
437 <DT><B>Returns:</B><DD>The length, in bytes, of the file denoted by this file name, or 0 if the file does not exist.</DL>
442 <A NAME="exists()"><!-- --></A><H3>
445 public boolean <B>exists</B>()</PRE>
447 <DD>Indicates if the file exists in the flash memory.
451 <DT><B>Returns:</B><DD>True indicates the file exists, false means it has not been created.</DL>
456 <A NAME="format()"><!-- --></A><H3>
459 public static void <B>format</B>()</PRE>
461 <DD>Essentially formats the file system by writing TABLE_ID characters to
462 the first page of flash memroy. Also writes 0 as the number of files
463 in the file system, so it can be used to restart/erase all files.
471 <A NAME="createNewFile()"><!-- --></A><H3>
474 public boolean <B>createNewFile</B>()</PRE>
476 <DD>Creates a new file entry in the flash memory.
480 <DT><B>Returns:</B><DD>True indicates file was created in flash. False means it already existed or the size is 0 or less.</DL>
485 <A NAME="moveToTop()"><!-- --></A><H3>
488 public void <B>moveToTop</B>()</PRE>
490 <DD>move the file to become the last one in flash memory
498 <A NAME="freeMemory()"><!-- --></A><H3>
501 public static int <B>freeMemory</B>()</PRE>
509 <A NAME="getIndex()"><!-- --></A><H3>
512 public int <B>getIndex</B>()</PRE>
514 <DD>returns location of file in the files[] array
518 <DT><B>Returns:</B><DD>index of file in files[]</DL>
523 <A NAME="defrag()"><!-- --></A><H3>
526 public static void <B>defrag</B>()</PRE>
528 <DD>assumptions: the files[] array has no nulls, and is in increasing order by page_location
529 this scheme moves moves each file down to fill in the empty pages.
537 <A NAME="getPage()"><!-- --></A><H3>
540 public int <B>getPage</B>()</PRE>
546 <!-- ========= END OF CLASS DATA ========= -->
550 <!-- ======= START OF BOTTOM NAVBAR ====== -->
551 <A NAME="navbar_bottom"><!-- --></A>
552 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
553 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
555 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
556 <A NAME="navbar_bottom_firstrow"><!-- --></A>
557 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
558 <TR ALIGN="center" VALIGN="top">
559 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
560 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
561 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
562 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
563 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
564 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
565 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
569 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
575 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
576 <A HREF="../../java/io/DataOutputStream.html" title="class in java.io"><B>PREV CLASS</B></A>
577 <A HREF="../../java/io/FileInputStream.html" title="class in java.io"><B>NEXT CLASS</B></A></FONT></TD>
578 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
579 <A HREF="../../index.html?java/io/File.html" target="_top"><B>FRAMES</B></A>
580 <A HREF="File.html" target="_top"><B>NO FRAMES</B></A>
581 <SCRIPT type="text/javascript">
584 document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
589 <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
596 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
597 SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
598 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
599 DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
602 <A NAME="skip-navbar_bottom"></A>
603 <!-- ======== END OF BOTTOM NAVBAR ======= -->