My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.lineadecodigo.java.file;

import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;

/**
* @file VaciarContenidoFichero.java
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 31-julio-2010
* @url http://lineadecodigo.com/java/vaciar-el-contenido-de-un-fichero-con-java/
* @description Vaciar el contenido de un fichero mediante la escritura de una cadena vacĂ­a.
*/

public class VaciarContenidoFichero {

public static void main(String[] args) {

String sFichero = "fichero1.txt";

try{
BufferedWriter bw = new BufferedWriter(new FileWriter(sFichero));
bw.write("");
bw.close();
} catch (FileNotFoundException fnfe){
fnfe.printStackTrace();
} catch (IOException ioe){
ioe.printStackTrace();
}
}


}

Change log

r264 by vcuervo on Jul 30, 2010   Diff
Vaciar el contenido de un fichero con Java
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 885 bytes, 35 lines
Powered by Google Project Hosting