|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--orgposada.urlpos.URLTextReader
Lee un archivo con un URL.
Field Summary | |
private java.io.BufferedReader |
buffRead
Lector temporal. |
private java.io.InputStream |
inpStr
Corriente de entrada. |
private java.io.InputStreamReader |
inpStrRead
Lector de la corriente de entrada. |
java.lang.String |
IS_DIRECTORY
Constante para localizar a un directorio. |
java.lang.String |
IS_FILE
Constante para localizar a un archivo. |
java.lang.String |
STRING_DIRECTORY
Prefijo de un directorio. |
java.lang.String |
STRING_FILE
Prefijo de un archivo. |
private java.net.URLConnection |
urlConn
Conexion al URL. |
Constructor Summary | |
URLTextReader()
|
Method Summary | |
void |
closeFile()
Libera los recursos usados para el archivo. |
private void |
crossDirectory(java.lang.String fullPathFile,
java.lang.String indent,
java.lang.StringBuffer strBuffTree)
Recorre un directorio de forma recursiva. |
java.lang.StringBuffer |
getFileContent()
Deprecated. Usar readFileContent() |
java.lang.String |
navigateDirectory(java.net.URL baseURL)
Recorre un directorio de forma recursiva. |
java.io.BufferedReader |
openFile(java.lang.String fullPathFile)
Deprecated. Usar readFileContent() o cambiar codigo funciona bien para *.XML, *.HTML |
java.io.BufferedReader |
openFile(java.lang.String CodeBase,
java.lang.String RelativePathFile)
|
java.lang.StringBuffer |
readFileContent(java.lang.String fullPathFile)
Abre, lee el contenido del archivo y lo cierra. |
static java.net.URL |
validateURLWithFile(java.net.URL urlBase,
java.lang.String strPathFile)
Valida la union de un URL y una cadena con ruta/archivo. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public final java.lang.String IS_DIRECTORY
public final java.lang.String IS_FILE
public final java.lang.String STRING_DIRECTORY
public final java.lang.String STRING_FILE
private java.net.URLConnection urlConn
private java.io.BufferedReader buffRead
private java.io.InputStream inpStr
private java.io.InputStreamReader inpStrRead
Constructor Detail |
public URLTextReader()
Method Detail |
public java.io.BufferedReader openFile(java.lang.String CodeBase, java.lang.String RelativePathFile) throws java.net.MalformedURLException, java.net.UnknownServiceException, java.io.IOException, java.lang.Exception
CodeBase
- Ejemplo: "http://www.cimat.mx/~posada/ReadURLFile/"RelativePathFile
- Ejemplo: "DirPrueba/test.txt"public java.io.BufferedReader openFile(java.lang.String fullPathFile) throws java.net.MalformedURLException, java.net.UnknownServiceException, java.io.IOException
fullPathFile
- Ejemplo: "/Datos/Documento.txt"java.net.MalformedURLException
- Si el protocolo no es conocido.
No existe el archivo.java.io.IOException
- No se abre bien la conexion.java.net.UnknownServiceException
- Problemas en el InputStream.closeFile()
public void closeFile() throws java.io.IOException
java.io.IOException
- No se pudo cerrar correctamente.public java.lang.StringBuffer getFileContent() throws java.io.IOException
java.io.IOException
- No se pudo leer correctamente.public java.lang.StringBuffer readFileContent(java.lang.String fullPathFile) throws java.net.MalformedURLException, java.io.IOException
URLTextReader utr; String sURL = null; BufferedReader buffRead; StringBuffer strBuffFile = new StringBuffer(); try { //String urlBase = getCodeBase(); //TextField tfURL; sURL = URLTextReader.validateURLWithFile( urlBase, tfURL.getText() ).toString(); utr = new URLTextReader(); strBuffFile = utr.readFileContent(sURL); } catch (MalformedURLException mue) { throw new Exception( "Favor de escribir un URL valido."); } catch (IOException ioe) { throw new Exception( "Problemas en la lectura del archivo."); } catch (Exception e) { throw new Exception( "Problemas con los Streams u otros."); }
java.io.IOException
- No se pudo leer correctamente.Object.toString()
public static java.net.URL validateURLWithFile(java.net.URL urlBase, java.lang.String strPathFile) throws java.lang.IllegalArgumentException, java.net.MalformedURLException
urlBase
- La ruta o CodeBase de la clase. Se asume que termina
con "/".
Ejemplo: \oposada\JavaSource\ProgAvan\JavaProg\pack10strPathFile
- Cadena con ruta y archivo.java.lang.IllegalArgumentException
- Si strPathFile vacio.java.net.MalformedURLException
- URL invalido.public java.lang.String navigateDirectory(java.net.URL baseURL) throws java.io.IOException
FILE Hola mundo.txt DIR Mis Documentos FILE Musica.mp3 FILE Perro.gif DIR MisHTML
baseURL
- Direccion URL valida.java.io.IOException
- No se pudo leer el contenido del directorioprivate void crossDirectory(java.lang.String fullPathFile, java.lang.String indent, java.lang.StringBuffer strBuffTree) throws java.io.IOException
strBuffTree
- Salida donde se agregan los archivosindent
- Nivel de indentado.java.io.IOException
- No se pudo leer el contenido del directorio
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |