Blog y foros sobre Java en español. ¡¡No dudes en preguntar!!

Wifi Reminder para Android - Recupera la contraseña de tu red

Wifi Reminder¿Aún no has probado Wifi Reminder?

Wifi Reminder te permite recuperar la contraseña de tu red Wifi si la olvidas. Actualmente funciona con las redes WLAN_XXXX y JAZZTEL_XXXX, de Movistar y Jazztel. Estas redes aparecerán en el listado con fondo verde.

Actualmente no funciona con las redes WLAN_XX.

Wifi Reminder está diseñada para recuperar tus propias contraseñas. El autor de Wifi Reminder no se hace responsable del mal uso que se le pueda dar a la herramienta.

Para sugerencias y errores: o mediante correo electrónico.

Actualización: Google ha retirado Wifi Reminder del Android Market. Aquí dejo un enlace a la descarga:

Descargar Wifi Reminder

El FBI cierra Megaupload

Como noticia de última hora, y precisamente el día después de la "huelga" digital en protesta contra la ley SOPA, el FBI ha cerrado el sitio de descargas donde precisamente Java-Spain almacena archivos como el programa Wifi Reminder, lo cual no supone ninguna ilegalidad, "ni aquí ni en la China" como se suele decir, aunque en este caso no estaría muy claro. ;-)
Esperemos que esto sea algo temporal puesto que en caso contrario supone una clara amenaza contra la libertad digital y la neutralidad de la red.
Podéis seguir las últimas noticias en Twitter (#Megaupload)

Converting a String into a number

In this short and simple post we are going to explain how to get an int or long number from a String.

It is as easy as doing this:

int i = 0;
long l = 0;
String s = "100000";
try {
    // We get an int from s
    i = Integer.parseInt(s);
    // We get a long from s
    l = Long.parseLong(s);
} catch(NumberFormatException nfe) {
    System.err.println("The String " + s + " is not a valid number.");
} changes its look

I am glad to announce that Java-Spain, due to its first year of life it is going to update its look to fit into the current trends of design. I hope you like it.

Formatting numbers: NumberFormat

First of all, I would say that this class is very useful to print numbers on screen while managing the format they will have. Soon we will write another post about DecimalFormat, which inherits from this one.

NumberFormat is the simplest one. It mainly has these methods:

  • getInstance() - Just obtains the current language format.
  • getCurrencyInstance() - Same as getInstance, but with currency format.

and their overloads with a Locale parameter that will replace the current language.

To give the appropiate format it will be neccessary to invoke the format() method, as you will see next.

This class is a very adaptative util when formatting numbers. As always, I will look up the Java Docs to explain it, as it is our most appreciated resource ;-).

import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class PruebaFormatos {
	public static void main(String[] args) {
                 * We start with getInstance() method, the simplest one.
		 * It just converts the numbers to the default locale format
		 * (Spanish in my case).
		NumberFormat nf = NumberFormat.getInstance();
		// Result: 76.543.210
		// Now with a different locale (English)
		nf = NumberFormat.getInstance(Locale.ENGLISH);
		// Result: 76,543,210
		 * getIntegerInstance method, it rounds decimal numbers.
		 * Attention! it rounds, it doesn't truncate!
		nf = NumberFormat.getIntegerInstance();
		// Result: 123.457
		// Now in French
		nf = NumberFormat.getIntegerInstance(Locale.FRENCH);
		// Result: 123 457
		/* I'll show you how to print the money I have in my bank account: */
		nf = NumberFormat.getCurrencyInstance();
		// Result: 12.345.678,00 € (That would be great! :-P)
		// Now in US Dollars
		nf = NumberFormat.getCurrencyInstance(Locale.US);
		System.out.println(nf.format(12345678 * 1.5023));
		// Result: $18,546,912.06
		 * At least, we are going to parse an integer. In this case it doesn't apply
		 * any format.
		try {
			nf = NumberFormat.getInstance();
			System.out.println(nf.parseObject("76543210 Euros"));
		} catch (ParseException e) {
			// TODO Auto-generated catch block

¿Qué funciones o mejoras echas de menos en Java-Spain? Se admiten sugerencias en los comentarios

Basic usage of arrays, ArrayList and Vector. Converting arrays.

Today we have chosen a simple-but-no-least topic due to the common use of all of these classes and the utilities they provide us when manipulating sets of items.
First of all, we are going to initialize an array of String, whose size is determined at the moment of creation. To avoid this 'problem' we have some other collections.
Two of them are ArrayList and Vector. An ArrayList is an implementation of List, which is a collection that admits duplicated and null elements, as well as indexed access and some other methods to handle its elements. Vector class also inherits from List and behaves almost like ArrayList with some differences: Vector is 'thread safe' which means that if we intend to modify a Vector from two different threads, it will throw an exception. It is also called a syncronized class. This advantage implies a small handicap when talking about performance.
Before giving an example, I would like to recall that since version 1.5 of Java, if I am right, generic collections were introduced, and that involves an improvement as they support compile-time type checking. To define the type of the collection used, simply add 'less than' and 'greater than' simbols: '<' & '>' (e.g. Vector<String>).
Now, it is time for an example:

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;
public class Test1 {
    public static void main(String[] args) {
        String[] arrayString = new String[]{"1", "2", "3", "4"};
        for (int i = 0; i < arrayString.length; i++) {
        ArrayList<String> arrayList = new ArrayList<String>(arrayString.length);
        for (int i = 0; i < arrayString.length; i++) {
        Iterator it = arrayList.iterator();
        while(it.hasNext()) {
        Vector<String> vector = new Vector<String>(arrayString.length);
        for (int i = 0; i < arrayString.length; i++) {
        it = vector.iterator();
        while(it.hasNext()) {

Google Wave Invitations - Come and get one!!

Today we have received a new "wave" of Google Wave invitations (they are really "nominations"). We will give them away to the first eight people who write a comment in this post. Do not forget to write your email correctly in the proper field.
See you guys!!

First bilingual post - Java-Spain also available in English

Java-Spain has been online for more than a year and we are starting to translate all the contents generated until now. This is a Beta project, so it is possible that you will see some weird stuff until we polish it completely. I would thank you all visitors for correcting the gramatical mistakes that you could find.

You are welcome!!

Syndicate content