Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- //Create a file writer that will write the file
- FileWriter fw = new FileWriter("c://Users/Mike/workspace/"+filename);
- //Create print writer
- PrintWriter fp = new PrintWriter(fw);
- //Print to the file each line coming in from the client
- String fileLine;
- while((fileLine = bf.readLine()) != null) {
- fp.println(fileLine);
- System.out.println("added line "+fileLine);//test by printing to console
- }
- // if (fp == null) { // !!! NO !!!
- if (fp != null) { // !! YES !!!
- //close the file printer, inform the client the upload is complete
- fp.close();
- out.println("Upload Complete!"); // ?? should this be System.out.println(...)??
- } else {
- System.out.println("fp already null -- upload complete");
- }
- } catch(IOException e) {
- e.printStacktrace();
- }
Add Comment
Please, Sign In to add comment