Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2010, 10:43
Avatar de robertgustavo
robertgustavo
 
Fecha de Ingreso: marzo-2008
Ubicación: Camaná - Arequipa
Mensajes: 213
Antigüedad: 16 años, 1 mes
Puntos: 4
Caracter raro, cuando uso strtok

hola, estoy haciendo una aplicacion de consola de java, y estoy leendo datos de un fichero de texto (.txt)

estos datos tengo de ejemplo en el fichero: mi programa los insertó!

0000001|AMD PHENOM II X6 1080T SIX CORE|PROCESADORES|Unidad|3|1200.0|1.0|02/07/2010|C:\Documents and Settings\Roberth\Mis documentos\imagenes\cpu_amd_phenomii x6.jpg
0000002|Gigabyte RADEON HD 5870 256 BIT|VIDEOCARDS|Unidad|3|1600.0|0.0|02/07/2010|C:\Documents and Settings\Roberth\Mis documentos\imagenes\vid_gb_hd5870_1gbddr5.jpg


como ven cada dato esta separado por un "|" , TODOS ESOS DATOS QUIERO SUBIRLOS A OBJETOS PRODUCTOS, QUE DECLARO , SEGUN LA CANTIDAD DE FILAS QUE EXISTAN EN EL TXT Y ESTE ES MI CODIGO, PARA SUBIR A MI OBJETO

CLASE PRODUCTO; Q TIENE UN CONSTRUCTOR Y SUS GET Y SET PERO NO LOS PONGO

Código PHP:
public class Producto
{
    
//Varibles Miembro
    
private String Codigo;
    private 
String Descripcion
    private 
String Categoria
    private 
String UnidadMedida
    private 
int Stock;
    private 
double PrecioUnitario;
    private 
int Descuento;
    private 
String FechaVencimiento;
    private 
String ImageFile;



Código PHP:
    private void CargarProductos() throws FileNotFoundExceptionIOException
    
{
       
//Booleanos para saber si ya se subio a memoria, cuando se estubo rrecorriendo la fila con el strtock
       
boolean Codinsert=false;
       
boolean Descripinsert=false;
       
boolean CatInsert=false;
       
boolean MedInsert=false;
       
boolean StockInsert=false;
       
boolean PrecioInsert=false;
       
boolean DescuInsert=false;
       
boolean VencInsert=false;
       
boolean ImageInsert=false;
       
item=new Producto[this.NumeroFilas()];
       
int i=1;
       for(
i=1;i<=this.NumeroFilas();i++)
       {
                      
BufferedReader Reader = new BufferedReader(new FileReader(Fichero));
                      while((
Cd Reader.readLine())!=null)//Lee lineas
                      
{
                          
//SACA LOS DATOSDE LA FILA
                          
StringTokenizer stoken  = new StringTokenizer(Cd,"|");
                          
String ItemFila=stoken.nextToken().trim();
                          while (
stoken.hasMoreTokens())
                          {
                              if(
Codinsert==false)
                              {
                                  
System.out.println(ItemFila.toString());
                                 
item[i].setCodigo(ItemFila);
                                  
Codinsert=true;
                                  break;
                              }

                              if(
Descripinsert==false)
                              {
                                  
item[i].setDescripcion(ItemFila);
                                  
Descripinsert=true;
                                  break;
                              }
                              if(
CatInsert==false)
                              {
                                  
item[i].setCategoria(ItemFila);
                                  
CatInsert=true;
                                  break;
                              }
                              if(
MedInsert==false)
                              {
                                  
item[i].setUnidadMedida(ItemFila);
                                  
MedInsert=true;
                                  break;
                              }
                              if(
StockInsert==false)
                              {
                                  
item[i].setStock(Integer.parseInt(ItemFila));
                                  
StockInsert=true;
                                  break;
                              }
                              if(
PrecioInsert==false)
                              {
                                  
item[i].setPrecioUnitario(Double.parseDouble(ItemFila));
                                  
PrecioInsert=true;
                                  break;
                              }
                              if(
DescuInsert==false)
                              {
                                  
item[i].setDescuento(Integer.parseInt(ItemFila));
                                  
DescuInsert=true;
                                  break;
                              }
                              if(
DescuInsert==false)
                              {
                                  
item[i].setDescuento(Integer.parseInt(ItemFila));
                                  
DescuInsert=true;
                                  break;
                              }
                              if(
VencInsert==false)
                              {
                                  
item[i].setFechaVencimiento(ItemFila);
                                  
VencInsert=true;
                                  break;
                              }                          
                              if(
ImageInsert==false)
                              {
                                  
item[i].setImageFile(ItemFila);
                                  
ImageInsert=true;
                                  break;
                              }
                              
ItemFila=stoken.nextToken().trim();
                          }
                      }
                      
Reader.close();
       }
    } 

PROBLEMA: imprime un caracter tipo .0000001

miren la imagen:

http://photos1.hi5.com/0134/252/152/jFkGWT252152-02.jpg


espero puedan ayudarme, gracias
__________________
Soluciones basadas en .NET Framework y SQL Server