Java - while en java

 
Vista:
Imágen de perfil de Emilio

while en java

Publicado por Emilio (4 intervenciones) el 24/11/2014 21:46:20
Me pueden apoyar...con esto... necesito hacer funcionar el while, marca error en la instruccion if

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.Scanner;
 
 
public class Datos {
public static void main(String[] args) {
 
 
@SuppressWarnings("resource")
Scanner sc = new Scanner(System.in);
 
String nombre;
String dire;
String tele;
String email;
 
System.out.print("Introduzca su Nombre: ");
nombre = sc.nextLine();
 
System.out.print("Introduzca su Direccion: ");
dire = sc.nextLine();
 
System.out.print("Introduzca su Telefono: ");
tele = sc.nextLine();
 
System.out.print("Introduzca su Email: ");
email = sc.nextLine();
 
System.out.println("Tu Nombre es:" + nombre);
System.out.println("Tu Direccion es: " + dire);
System.out.println("Tu Telefono es:" + tele);
System.out.println("Tu email es:" + email);
 
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int salir = 1;
String str=new String();
while (salir==1){
 
 
System.out.println("¿Desea salir?");
str = br.readLine(22);
if (str.equals ("si")
{
salir = 0;
}
}
String sFichero = "d:\\fichero.txt";
File fichero = new File(sFichero);
 
 
try{
 
 
if(!fichero.exists()){
fichero.createNewFile();}
 
 
BufferedWriter Fescribe=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fichero,true), "utf-8"));
 
Fescribe.write("Nombre: "+nombre);
Fescribe.newLine();
Fescribe.write("Direccion: "+dire);
Fescribe.newLine();
Fescribe.write("Telefono : "+tele);
Fescribe.newLine();
Fescribe.write("Email : "+email);
Fescribe.newLine();
 
System.out.println("Tus Datos han Sido Grabados en tu USB");
 
 
 
Fescribe.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());}}}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 686
Bronce
Ha mantenido su posición en Java (en relación al último mes)
Gráfica de Java

while en java

Publicado por xve (345 intervenciones) el 24/11/2014 22:05:34
Hola Emilio, no indicas que error te da, pero creo que el problema es que te falta cerrar un paréntesis... puede ser?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

while en java

Publicado por Victor (1 intervención) el 26/10/2016 01:48:27
Yo veo que al solucionar el error en la linea donde dices que es el ultimo parentesis, ademas aparece un error de compatibilidad en la linea donde dice str = br.readLine(22);, usa boolean o usa expresiones que se puedan comparar, o creo que solo a mi me aparece ese error porque me falta una declaracion
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar