Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

FileUpload not working

$
0
0
Hi ,
I am having an issue with the FileUpload component .
What I am doing is capturing the content of a screen which looks like a xsl
file and trying to upload this content to a file .
I store the screen data in a byte array .

Should this work .Thanks for your help .

here is the main part of the code .

uploadedFile is of type FileUpload

AbstractResourceStreamWriter rstream = new AbstractResourceStreamWriter() {

OutputStream outputStream = null;

public void write(OutputStream output) throws IOException {
try {
outputStream = output;

newFile = new File(fileNamePath);

if (newFile.exists()) {
newFile.delete();
newFile.createNewFile();

outputStream = new FileOutputStream(newFile);
outputStream.write(xlsOutput); // xlsOutput byte[]

uploadedFile.writeTo(newFile);

} catch (Exception ex) {
logger.error("Unable to write to the file specified in the search path
while trying to Export the File");
StringWriter stringWriter = new StringWriter();
ex.printStackTrace(new PrintWriter(stringWriter));
logger.error(stringWriter.toString());

@Override
public void close() {
try {
outputStream.close();
uploadedFile.closeStreams();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();

};

RequestCycle.get().scheduleRequestHandlerAfterCurrent(new
ResourceStreamRequestHandler(rstream, null));

Viewing all articles
Browse latest Browse all 5648

Trending Articles