X FAVOR CONTESTARME

laury19
26 de Agosto del 2004
este es un progra q he hexo sobre fixeros.. y m dan una serie d errores (kizas mu tontos) pero sq no los veo.... y kisiera q x favor si alguien m puede ayudar... m exe una mano.. gracias

este es el programa:

import java.io.*;
class Registro{
private double ISBN;
private String titulo, autor;
private int año;
Registro (double isbn, String t, String a, int y)throws IOException{
ISBN = isbn;
titulo=t;
autor=a;
año=y;
}
public double dev_ISBN(){
return ISBN;
}
public String dev_titulo(){
return titulo;
}
public String dev_autor(){
return autor;
}
public int dev_año(){
return año;
}
}
class Fichero{
private DataInputStream ent;
boolean fin;
Fichero (String nombre){
fin=false;
try{
ent= new DataInputStream (new FileInputStream (nombre));
}
catch (IOException e){
}
//retorna si nos encontramos al final del fichero
public boolean eof(){
return fin;
}
public Registro leer(){
Registro reg=null;
try{
//lee un registro del fichero
reg=new Registro(ent.readDouble(),ent.readUTF(),ent.readUTF(),ent.readInt());
return reg;
}
//captura la excepcion de fin de fichero
catch (EOFException eof){
fin=true;
}
catch (IOException e){
return reg;
}
}
public void cerrar(){
try{
ent.close();
}
catch (IOException e){
}

}
class Test{
public static void main (String args[]){
Registro reg;
//Crea un flujo de entrada
Fichero archivo_secu=new Fichero ("biblio.txt");
//lee un registro del archivo
reg=archivo_secu.leer();
/*mientras q no se encuentre el final del fichero sigue leyendo*/
while (!archivo_secu.eof()){
System.out.println("ISBN : " +reg.dev_ISBN());
System.out.println("TITULO : " +reg.dev_titulo());
System.out.println("AUTOR : " +reg.dev_autor());
System.out.println("AÑO : " +reg.dev_año());
reg=archivo_secu.leer();
}
archivo_secu.cerrar();
}
}

....................................................................................................
y los errores q m dan:

C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:36: illegal start of expression
public boolean eof(){
^
C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:61: ';' expected
}
^
C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:79: '}' expected
}
^
C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:68: cannot resolve symbol
symbol : method leer ()
location: class Fichero
reg=archivo_secu.leer();
^
C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:70: cannot resolve symbol
symbol : method eof ()
location: class Fichero
while (!archivo_secu.eof()){
^
C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:75: cannot resolve symbol
symbol : method leer ()
location: class Fichero
reg=archivo_secu.leer();
^
C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:77: cannot resolve symbol
symbol : method cerrar ()
location: class Fichero
archivo_secu.cerrar();
^
C:Archivos de programaXinox SoftwareJCreatorMyProjectsEJEMPLOprueba.java:63: inner classes cannot have static declarations
public static void main (String args[]){
^
8 errors
Process completed.

cgteevin
26 de Agosto del 2004
package laury19;
import java.io.*;
class Fichero {
private DataInputStream ent;
boolean fin;
public Fichero(String nombre) {
fin = false;
try {
ent = new DataInputStream(new FileInputStream(nombre));
} catch (IOException e) {}
//retorna si nos encontramos al final del fichero
}
public boolean eof() {
return fin;
}
public Registro leer() {
Registro reg = null;
try {
//lee un registro del fichero
reg =
new Registro(
ent.readDouble(),
ent.readUTF(),
ent.readUTF(),
ent.readInt());
return reg;
}
//captura la excepcion de fin de fichero
catch (EOFException eof) {
fin = true;
} catch (IOException e) {
return reg;
} finally {
return reg;
}
}
public void cerrar() {
try {
ent.close();
} catch (IOException e) {}
}

}

package laury19;
import java.io.*;
class Registro {
private double ISBN;
private String titulo, autor;
private int año;
Registro(double isbn, String t, String a, int y) throws IOException {
ISBN = isbn;
titulo = t;
autor = a;
año = y;
}
public double dev_ISBN() {
return ISBN;
}
public String dev_titulo() {
return titulo;
}
public String dev_autor() {
return autor;
}
public int dev_año() {
return año;
}
}

package laury19;

/**
* @author TeevinA
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
class Test {
public static void main(String args[]) {
Registro reg;
//Crea un flujo de entrada
Fichero archivo_secu = new Fichero("biblio.txt");
//lee un registro del archivo
reg = archivo_secu.leer();
/*mientras q no se encuentre el final del fichero sigue leyendo*/
while (!archivo_secu.eof()) {
System.out.println("ISBN : " + reg.dev_ISBN());
System.out.println("TITULO : " + reg.dev_titulo());
System.out.println("AUTOR : " + reg.dev_autor());
System.out.println("AÑO : " + reg.dev_año());
reg = archivo_secu.leer();
}
archivo_secu.cerrar();
}
}

laury19
26 de Agosto del 2004
HOLA HE VISTO Q M LO HAS REFORMADO... ESO SIGNIFICA.. Q ASI ESTA MJOR... SQ SOY UN POCO NOVATILLA.. Y M ESTA COSTANDO MUXISIMO ESTO DE LOS FICHERO.. ASI Q SI M DECIS Q ASI TA MJOR... LO CAMBIARE

GRACIAS

juan_guns8
26 de Agosto del 2004
Aqui te mando el codigo pero me bota un error solo es cuestion que lo mires
import java.io.*;
class Registro
{
private double ISBN;
private String titulo, autor;
private int año;

Registro (double isbn, String t, String a, int y)throws IOException
{
ISBN = isbn;
titulo=t;
autor=a;
año=y;
}
public double dev_ISBN()
{
return ISBN;
}
public String dev_titulo()
{
return titulo;
}
public String dev_autor()
{
return autor;
}
public int dev_año()
{
return año;
}
}
class Fichero
{
private DataInputStream ent;
boolean fin;

Fichero (String nombre)
{
fin=false;
try
{
ent= new DataInputStream (new FileInputStream (nombre));
}
catch (IOException e)
{

}
}
//retorna si nos encontramos al final del fichero
public boolean eof()
{
return fin;
}
public Registro leer()
{
Registro reg=null;
try
{
//lee un registro del fichero
reg=new Registro(ent.readDouble(),ent.readUTF(),ent.readUTF(),ent.readInt());
return reg;
}
//captura la excepcion de fin de fichero
catch (EOFException eof)
{
fin=true;
}
catch (IOException e)
{
return reg;
}
}
public void cerrar()
{
try
{
ent.close();
}
catch (IOException e)
{

}

}
}
class Test
{
public static void main (String args[])
{
Registro reg;
//Crea un flujo de entrada
Fichero archivo_secu=new Fichero ("biblio.txt");
//lee un registro del archivo
reg=archivo_secu.leer();
/*mientras q no se encuentre el final del fichero sigue leyendo*/
while (!archivo_secu.eof())
{
System.out.println("ISBN : " +reg.dev_ISBN());
System.out.println("TITULO : " +reg.dev_titulo());
System.out.println("AUTOR : " +reg.dev_autor());
System.out.println("AÑO : " +reg.dev_año());
reg=archivo_secu.leer();
}
archivo_secu.cerrar();
}
}

********************************************************
C:Documents and SettingssalasEscritorioRegistro.java:55: missing return statement
{
^
1 error

Process completed.

Antes eran ocho...............nos vemos

LeNnY
26 de Agosto del 2004
en el primer error, te sale porque el metodo esta dentro del constructor y eso es ilegal, los demas son puras comas, comillas y punto y comas que te faltan revisalos ahi mismo te dice en donde esta mal y por finalizar no reconoe alguna de tus variables o bien no han sido inicializadas, algunas veces debes evaluar muy bien si es que llamas en algun momento a una variable pues debes inicializarla antes