Tecnologia

Páginas: 3 (581 palabras) Publicado: 1 de agosto de 2012
public class PrgArchivo {
public static void main(String a [] ) {
String texto = "Hola Mundo";
RandomAccessFile file = null;
try {
file=newRandomAccessFile( "D:\\prueba.txt", "rw" );
} catch (Exception e) { }
try {
file.seek(file.length());
file.writeBytes(texto );
file.close();
System.out.println( "Grabacion de datos finalizada");} catch (IOException e) {
}System.exit(0); }
---------------------------------
public class ProgArchivo01 {
public static void main(String a[]){
String texto = "metodo de las 6D";RandomAccessFile file = null ;
try {
File fichero = new File( "D:\\prueba01.txt" ) ;
if ( fichero.delete ( ) ) {
System.out.println ( "Archivo Borrado...") ;
} else {System.out.println ( "Archivo no se haborrado..") ;
} } catch ( Exception e ) { }
try {
file = new RandomAccessFile("D:\\prueba01.txt","rw") ;
} catch ( Exception e ) { }
try {
file.seek ( file.length( ) ) ;
file.writeBytes (texto ) ;
file.close ( ) ;
System.out.println ( "Grabacion de datos finalizada..") ;
} catch ( IOException e ) { }
System.exit ( 0 ) ;}
---------------------------------
public class ProgArchivo04{
public static void main(String a [] ) {
String texto = "Hola Mundo";
RandomAccessFile file = null;
try {
file=new RandomAccessFile( "D:\\prueba04.txt", "rw" );
} catch (Exception e){ }
try {
file.seek(file.length());
file.writeBytes(texto + "\n");
file.close();
System.out.println( "Grabacion de datos finalizada...");
} catch (IOException e) {
}System.exit(0); }-----------------------------------
public class ProgArchivo05
public static void main(String a [] ) {
String texto = "Hola Mundo";
StringsaltoLinea=System.getProperty("line.separator");RandomAccessFile file = null;
try {file=new RandomAccessFile( "D:\\prueba05.txt", "rw" );
} catch (Exception e) { }
try { file.seek(file.length());
file.writeBytes(texto + saltoLinea); file.close();...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Tecnologia
  • Tecnología
  • Tecnologia
  • Tecnologia
  • Tecnologia
  • Tecnologia
  • Tecnologia
  • Tecnologia

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS