// // Telefonos.java // Copyright (c) 1996, Agustin Froufe // Todos los derechos reservados. // // No se asume ninguna responsabilidad por el uso o alteracion de este // software. Este software se proporciona COMO ES, sin garantia de ningun // tipo de su funcionamiento y en ningun caso sera el autor responsable de // daņos o perjuicios que se deriven del mal uso del software, aun cuando // este haya sido notificado de la posibilidad de dicho daņo. // // Compilador: javac 1.0 // Autor: Agustin Froufe // Creacion: 08-Oct-1996 06:43:16 // //-------------------------------------------------------------------------- // Esta informacion no es necesariamente definitiva y esta sujeta a cambios // que pueden ser incorporados en cualquier momento, sin avisar. //-------------------------------------------------------------------------- import java.io.*; class Telefonos { static FileOutputStream fos; public static final int longLinea = 81; public static void main( String args[] ) throws IOException { byte tfno[] = new byte[longLinea]; byte nombre[] = new byte[longLinea]; fos = new FileOutputStream( "telefono.dat" ); while( true ) { System.err.println( "Teclee un nombre ('Fin' termina)" ); leeLinea( nombre ); if( "fin".equalsIgnoreCase( new String( nombre,0,0,3 ) ) ) break; System.err.println( "Teclee el numero de telefono" ); leeLinea( tfno ); for( int i=0; tfno[i] != 0; i++ ) fos.write( tfno[i] ); fos.write( ',' ); for( int i=0; nombre[i] != 0; i++ ) fos.write( nombre[i] ); fos.write( '\n' ); } fos.close(); } private static void leeLinea( byte linea[] ) throws IOException { int b = 0; int i = 0; while( (i < ( longLinea-1) ) && ( ( b = System.in.read() ) != '\n' ) ) linea[i++] = (byte)b; linea[i] = (byte)0; } } //----------------------------------------- Final del fichero Telefonos.java