Basta con poner esta línea en la barra de tu navegador:
data:text/html, <html contenteditable>
Para leer el archivo se puede hacer de la siguiente manera:import java.io.IOException;import java.util.List;
import org.jdom.Document; //
import org.jdom.Element; // Librerías
import org.jdom.JDOMException; // JDOM
import org.jdom.input.SAXBuilder; //
...
public void cargarXml(){
//Se crea un SAXBuilder para poder parsear el archivo
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File( "archivo.xml" );
try{
//Se crea el documento a traves del archivo
Document document = (Document) builder.build( xmlFile );
//Se obtiene la raiz 'tables'
Element rootNode = document.getRootElement();
//Se obtiene la lista de hijos de la raiz 'tables'
List list = rootNode.getChildren( "tabla" );
//Se recorre la lista de hijos de 'tables'
for ( int i = 0; i < list.size(); i++ ){
//Se obtiene el elemento 'tabla'
Element tabla = (Element) list.get(i);
//Se obtiene el atributo 'nombre' que esta en el tag 'tabla'
String nombreTabla = tabla.getAttributeValue("nombre");
System.out.println( "Tabla: " + nombreTabla );
//Se obtiene la lista de hijos del tag 'tabla'
List lista_campos = tabla.getChildren();
System.out.println( "\tNombre\t\tTipo\t\tValor" );
//Se recorre la lista de campos
for ( int j = 0; j < lista_campos.size(); j++ ){
//Se obtiene el elemento 'campo'
Element campo = (Element)lista_campos.get( j );
//Se obtienen los valores que estan entre los tags ' '
//Se obtiene el valor que esta entre los tags ' '
String nombre = campo.getChildTextTrim("nombre");
//Se obtiene el valor que esta entre los tags ' '
String tipo = campo.getChildTextTrim("tipo");
//Se obtiene el valor que esta entre los tags ' '
String valor = campo.getChildTextTrim("valor");
System.out.println( "\t"+nombre+"\t\t"+tipo+"\t\t"+valor);
}
}
}catch ( IOException io ) {
System.out.println( io.getMessage() );
}catch ( JDOMException jdomex ) {
System.out.println( jdomex.getMessage() );
}
}
public class Prueba1 {
public static void main(String[] args){
try {
metodoExcepcion1();
metodoExcepcion2();
} catch (IOException e) {
e.printStackTrace();
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
static void metodoExcepcion1() throws IOException{}
static void metodoExcepcion2() throws NumberFormatException {}
}
Con la utilización del bloque multicatch el mismo código quedaría de la siguiente forma:
try {
exceptionMethod1();
exceptionMethod2();
} catch (IOException | NumberFormatException e) {
e.printStackTrace();
}
String letra= "A";
switch (choice){
case "A":
System.out.println("Elegido letra A");
break;
case "B":
System.out.println("Elegido letra B");
break;
case "C":
System.out.println("Elegido letra C");
break;
}
Veamos un ejemplo de como crear un HaspMap con javascript
var myArray = new Array();
myArray['uno'] = 1;
myArray['dos'] = 2;
myArray['tres'] = 3;
Ahora veamos una manera de recorrer el HashMap recuperar la clave y el valor.
// Muestra la clave y los valores.
for (var i in myArray) {
alert('Clave : ' + i + ', Valor: ' + myArray[i]);
}
StringBuffer holamundoBuffer = new StringBuffer();
holamundoBuffer.append("Hola, ");
holamundoBuffer.append("mundo");
String holamundo = holamundoBuffer.toString();
StringBuilder holamundoBuilder = new StringBuilder();
holamundoBuilder.append("Hola, ");
holamundoBuilder.append("mundo");
String holamundo = holamundoBuilder.toString();