<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rss version="2.0">
 <channel>
  <title>Mañas Geek.</title>
  <link>http://rodrigo-salado-anaya.blog.com/</link>
  <description>Blog dedicado a Geek's.</description>
  <language>es-ES</language>
  <pubDate>Thu, 05 Jun 2008 03:04:32 +0200</pubDate>
  <lastBuildDate>Thu, 05 Jun 2008 03:04:32 +0200</lastBuildDate>
  <generator>Blog.com</generator>
    <item>
   <guid>http://rodrigo-salado-anaya.blog.com/3187827/</guid>
   <title>Renombrar un archivo en Java (rename).</title>
   <link>http://rodrigo-salado-anaya.blog.com/3187827/</link>
   <description>Usando la clase "existe" ya posteada, pongo esta que nos renombra un archivo. De hecho es muy facíl hacerlo pero, es tu decisión si lo cambias o mejoras, solo te pido que me lo hagas saber.<br />
/**<br />
&#160;*<br />
&#160;* @author rodrigo salado anaya.<br />
&#160;*/<br />
import java.io.File;<br />
<br />
public class rename {<br />
<br />
&#160;&#160;&#160; File file;<br />
&#160;&#160;&#160; File fileTemp;<br />
<br />
&#160;&#160;&#160; public&#160; rename(String path, String temp) {<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; /*Comprobamos su existencia*/<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; existe arch = new existe();<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!arch.existe(temp)) {<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; /*borramos basura*/<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; path = null;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arch = null;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; file = null;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; new utilidad.gc();<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />
<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; file = new File(path);<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; fileTemp = new File(temp);<br />
&#160;&#160;&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!fileTemp.renameTo(file)) {<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.out.println("No se pudo actualizar el systema.");<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />
&#160;&#160;&#160; }<br />
}<br /></description>
   <author>trade</author>
   <pubDate>Wed, 04 Jun 2008 21:11:51 +0200</pubDate>
  </item>
  </channel>
</rss>