MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuel d'utilisateur Page 245

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 408
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 244
Example – Creating and Using a Phone Book
5-75
if r == 'y',
try
FOS = java.io.FileOutputStream(pbname);
FOS.close
catch
error(sprintf('Failed to create %s', pbname));
end;
else
return;
end;
end;
3. Create a Hash Table
The example constructs a java.util.Properties object to serve as the hash
table for the data dictionary.
pb_htable = java.util.Properties;
4. Create a File Input Stream
In a try block, the example invokes a FileInputStream constructor with the
name of the phone book file, assigning the object to
FIS. If the call fails, the
catch statement displays an error message and terminates the program.
try
FIS = java.io.FileInputStream(pbname);
catch
error(sprintf('Failed to open %s for reading.', pbname));
end;
5. Load the Phone Book Keys and Close the File Input Stream
The example calls load on the FileInputStream object FIS, to load the phone
book keys and their values (if any) into the hash table. It then closes the file
input stream.
pb_htable.load(FIS);
FIS.close;
Vue de la page 244
1 2 ... 240 241 242 243 244 245 246 247 248 249 250 ... 407 408

Commentaires sur ces manuels

Pas de commentaire