G
gbattine
Hi guys,
i've a question for you.
I've a jsf application that interact with a mysql db.
In a mysql table i've 2 blob fields.
In the first i've a zip file that i've coded into an array of byte.
With this operation my application show to user the common
Open/Download window and it's ok
Blob blob = rs.getBlob("datigrezzi");
byte[] read = blob.getBytes(1, (int) blob.length());
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response =(HttpServletResponse)
context.getExternalContext().getResponse();
response.setContentType("application/zip");
response.setContentLength(read.length);
response.setHeader("Content-disposition", "attachment;
filename=\"yourfilename.zip\"");
response.getOutputStream().write(read); // bytes = the byte array.
context.responseComplete();
My problem is:
In the other blob field i've an array of byte but i can't download it
with my old method,because it has an internal format,that is it has all
the txt file reversed into one big row,with ; that indicates end of
line.
I have to restore original format that i can do with
Blob blob = rs.getBlob("datinormalizzati");
byte[] read = blob.getBytes(1, (int) blob.length());
String lettura = new String(read);
String[] arraylinee = lettura.split(";");
that gives me an array of string,each string is a row of my old file.
I have to download this array of string into a txt file,like the first
case, and i want open/download window...
can someone help me?
Thanks very much,help me with simple code,please...
i've a question for you.
I've a jsf application that interact with a mysql db.
In a mysql table i've 2 blob fields.
In the first i've a zip file that i've coded into an array of byte.
With this operation my application show to user the common
Open/Download window and it's ok
Blob blob = rs.getBlob("datigrezzi");
byte[] read = blob.getBytes(1, (int) blob.length());
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response =(HttpServletResponse)
context.getExternalContext().getResponse();
response.setContentType("application/zip");
response.setContentLength(read.length);
response.setHeader("Content-disposition", "attachment;
filename=\"yourfilename.zip\"");
response.getOutputStream().write(read); // bytes = the byte array.
context.responseComplete();
My problem is:
In the other blob field i've an array of byte but i can't download it
with my old method,because it has an internal format,that is it has all
the txt file reversed into one big row,with ; that indicates end of
line.
I have to restore original format that i can do with
Blob blob = rs.getBlob("datinormalizzati");
byte[] read = blob.getBytes(1, (int) blob.length());
String lettura = new String(read);
String[] arraylinee = lettura.split(";");
that gives me an array of string,each string is a row of my old file.
I have to download this array of string into a txt file,like the first
case, and i want open/download window...
can someone help me?
Thanks very much,help me with simple code,please...