G
gbattine
Can someone tell me how solve this problem?
I've a function that return an array of byte b[] and a main function
like this
byte x[]=null;
x=p.getBytes();
where p.getBytes() return the array of byte....how can i do?
Here is the code of getBytes() and main function...
public byte[] getBytes(){
byte middlerow=' ';
byte endrow=';';
Vector temp=new Vector(100000);
int i=0;
String g=null;
Riga r;
Double val[];
while(i<intest.length){
temp.addElement(intest.getBytes());
temp.addElement(Byte.valueOf(middlerow));
i++;
}
temp.addElement(Byte.valueOf(endrow));
System.out.println("Intestazione convertita in byte");
for(int l=0;l<rows.size()-1;l++){
r=(Riga)rows.get(l);
g=r.getgeneid();
temp.addElement(g.getBytes());
temp.addElement(Byte.valueOf(middlerow));
val=r.getvalues();
for(int e=0;e<=val.length-1;e++){
temp.addElement(Byte.valueOf(val[e].byteValue()));
temp.addElement(Byte.valueOf(middlerow));
}
temp.addElement(Byte.valueOf(endrow));
}
byte [] b=new byte[temp.size()];
for (int k=0;i<temp.size();i++){
b[k]=(((Byte)temp.elementAt(k)).byteValue());
}
return b;
}
public static void main(String[] args) throws IOException {
princ p=new princ();
p.carica();
System.out.println("Dati caricati");
byte x[]=null;
x=p.getBytes();
System.out.println("Byte convertiti");
FileOutputStream targetFile= new FileOutputStream(file); // define
the output stream
targetFile.write(x); //write the array of bytes to file
targetFile.flush();
targetFile.close(); //close the File stream
}
Thanks very much...
I've a function that return an array of byte b[] and a main function
like this
byte x[]=null;
x=p.getBytes();
where p.getBytes() return the array of byte....how can i do?
Here is the code of getBytes() and main function...
public byte[] getBytes(){
byte middlerow=' ';
byte endrow=';';
Vector temp=new Vector(100000);
int i=0;
String g=null;
Riga r;
Double val[];
while(i<intest.length){
temp.addElement(intest.getBytes());
temp.addElement(Byte.valueOf(middlerow));
i++;
}
temp.addElement(Byte.valueOf(endrow));
System.out.println("Intestazione convertita in byte");
for(int l=0;l<rows.size()-1;l++){
r=(Riga)rows.get(l);
g=r.getgeneid();
temp.addElement(g.getBytes());
temp.addElement(Byte.valueOf(middlerow));
val=r.getvalues();
for(int e=0;e<=val.length-1;e++){
temp.addElement(Byte.valueOf(val[e].byteValue()));
temp.addElement(Byte.valueOf(middlerow));
}
temp.addElement(Byte.valueOf(endrow));
}
byte [] b=new byte[temp.size()];
for (int k=0;i<temp.size();i++){
b[k]=(((Byte)temp.elementAt(k)).byteValue());
}
return b;
}
public static void main(String[] args) throws IOException {
princ p=new princ();
p.carica();
System.out.println("Dati caricati");
byte x[]=null;
x=p.getBytes();
System.out.println("Byte convertiti");
FileOutputStream targetFile= new FileOutputStream(file); // define
the output stream
targetFile.write(x); //write the array of bytes to file
targetFile.flush();
targetFile.close(); //close the File stream
}
Thanks very much...