Lectura de fichero txt
Estoy intentando hacer una funcion para leer caracter a caracter un fichero txt. y lo vaya mostrando por pantalla. De momento tengo:
import java.io.*;
public class Lectura{
public void main (String args[]) throws IOException
{
File fichero = new File("C:\Documents and Settings\workspace\Textos\texto.txt");
int c;
FileReader in = new FileReader(fichero);
while((c = in.read()) != -1)
{
System.out.println((char)c);
}
in.close();
}
}
Lo estoy haciendo con Eclipse.
Pero me da error al debugar en el main. Alguien me podria ayudar?? gracias
import java.io.*;
public class Lectura{
public void main (String args[]) throws IOException
{
File fichero = new File("C:\Documents and Settings\workspace\Textos\texto.txt");
int c;
FileReader in = new FileReader(fichero);
while((c = in.read()) != -1)
{
System.out.println((char)c);
}
in.close();
}
}
Lo estoy haciendo con Eclipse.
Pero me da error al debugar en el main. Alguien me podria ayudar?? gracias
Hola:
¿Por qué no pones el error que te da a ver si te podemos ayudar?
Se buena.
¿Por qué no pones el error que te da a ver si te podemos ayudar?
Se buena.
Vale, lo pongooooooo jejej se me habia pasado por alto.
Primero me da un aviso en el k q me pone :
Fatal exception ocurred. Program will exit.
Y luego ya en errores me dice:
java.lang.NoSuchMethodError: main
Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 ["util.c",L765]
JDWP exit error JVMTI_ERROR_INTERNAL(113):
Primero me da un aviso en el k q me pone :
Fatal exception ocurred. Program will exit.
Y luego ya en errores me dice:
java.lang.NoSuchMethodError: main
Exception in thread "main" ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 ["util.c",L765]
JDWP exit error JVMTI_ERROR_INTERNAL(113):
Hola de nuevo:
Te falta poner "static" en el main
public static void main (String [] args)
Se buena
Te falta poner "static" en el main
public static void main (String [] args)
Se buena
