Пример #1
0
 /**
  * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  *
  * @param request servlet request
  * @param response servlet response
  * @throws ServletException if a servlet-specific error occurs
  * @throws IOException if an I/O error occurs
  */
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/xml;charset=UTF-8");
   PrintWriter out = response.getWriter();
   try {
     // get exiting file, and output, looking for where to insert owners.
     BufferedReader in =
         new BufferedReader(
             new InputStreamReader(
                 this.getServletContext()
                     .getResourceAsStream(
                         "/WEB-INF/classes/gpt/search/browse/browse-catalog.xml")));
     log.fine("in: " + in.toString());
     String rec = null;
     while ((rec = in.readLine()) != null) {
       if (rec.contains("InsertOwnersHere")) {
         outputOwners(out);
       } else {
         out.println(rec);
       }
     }
   } finally {
     out.close();
   }
 }
Пример #2
0
 public boolean save(File file, String options) {
   PrintWriter writer = PApplet.createWriter(file);
   boolean result = write(writer);
   writer.flush();
   writer.close();
   return result;
 }