0

i need to generate a file in a popup after converting to the excel file. i'm using apache poi for this.

Here is my code:

try {
    FileInputStream file = new FileInputStream(new File("C:\\update.xls"));

   **excel coding here..**

    file.close();

    FileOutputStream outFile =new FileOutputStream(new File("C:\\update.xls"));
    workbook.write(outFile);
    outFile.close();

} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

what can i do in the FileOutputStream or something else and let user save it wherever they want?

2
  • How is the user interacting with your code? Swing? AWT? Web? Commented Nov 18, 2013 at 9:53
  • its a webapplication built in spring. Commented Nov 18, 2013 at 9:56

1 Answer 1

2

you are hard-coding the url C:\update.xls to file. Depending on your project, u can make a UI, add there ( a text field, where user can type desired file-name\path, or file-choose dialog). Or you can read file path from console. After retrieving the path, you create file with

FileOutputStream outFile =new FileOutputStream(new File(NewFilePath))

Sign up to request clarification or add additional context in comments.

1 Comment

not a probable solution. I wanna throw a popup to the user so that they can store it wherever they want. Its bad to ask them to enter the path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.