Netbeans - Deseo repetir la creación de un archivo

 
Vista:
sin imagen de perfil

Deseo repetir la creación de un archivo

Publicado por Ameppris (1 intervención) el 17/08/2018 00:40:34
Buen día
Deseo repetir la creación de un archivo dependiendo el For para ser más exactos
Sí ponen pago mensual crear 12 archivos si es anual 1 solo archivo tengo el siguiente código:
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
char mensual;
char trimestral;
char semestral;
char anual;
int i;
 
System.out.println("Ingresa la Negociacion");
Scanner scan = new Scanner(System.in);
String negociacion = scan.next();
System.out.println("Tipo de Pago");
String pago = scan.next();
if ("mensual".equalsIgnoreCase(pago))
    for(i=1;i<=12;i++){
        File Factura;
        try{
            Factura= new File ("C:\\Users\\SER_SIST\\Desktop\\Facturas\\"
                    + "Facturas\\Factura.pdf");
            if (Factura.createNewFile()){
                System.out.println("Se ha creado el archivo");
            }
        }catch(Exception ex){
            System.out.println("Error"+ex);
        }
        System.out.println(" " + negociacion +" "+ i);
    }
if("trimestral".equalsIgnoreCase(pago))
    for(i=1;i<=4;i++){
        File Factura;
     try{
         Factura= new File ("C:\\Users\\SER_SIST\\Desktop\\Facturas\\"
                 + "Facturas\\Facturatrimestral.pdf");
         if (Factura.createNewFile()){
             System.out.println("Se ha creado el archivo");
         }
     }catch(Exception ex){
         System.out.println("Error"+ex);
     }
        System.out.println(" " + negociacion +" "+ i);
    }
if("semestral".equalsIgnoreCase(pago))
    for(i=1;i<=2;i++){
        File Factura;
 try{
     Factura= new File ("C:\\Users\\SER_SIST\\Desktop\\Facturas\\"
             + "Facturas\\Facturasemestral.pdf");
     if (Factura.createNewFile()){
         System.out.println("Se ha creado el archivo");
     }
 }catch(Exception ex){
     System.out.println("Error"+ex);
 }
        System.out.println(" " + negociacion +" "+ i);
    }
 if("anual".equalsIgnoreCase(pago))
    for(i=1;i<=1;i++){
        File Factura;
 try{
     Factura= new File ("C:\\Users\\SER_SIST\\Desktop\\Facturas\\"
             + "Facturas\\Facturaanual.pdf");
     if (Factura.createNewFile()){
         System.out.println("Se ha creado el archivo");
     }
 }catch(Exception ex){
     System.out.println("Error"+ex);
 }
        System.out.println(" " + negociacion +" "+ i);
    }
}
}
Gracias
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