Functionality: Copy File
Clone type: Type-3 (WT3/4)
Is clone: TRUE

Function 1:
public void service (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    ServletContext context = getServletContext ();
    String forw = null;
    try {
        int maxUploadSize = 50000000;
        MultipartRequest multi = new MultipartRequest (request, ".", maxUploadSize);
        String descrizione = multi.getParameter ("text");
        File myFile = multi.getFile ("uploadfile");
        String filePath = multi.getOriginalFileName ("uploadfile");
        String path = "C:\\files\\";
        try {
            FileInputStream inStream = new FileInputStream (myFile);
            FileOutputStream outStream = new FileOutputStream (path + myFile.getName ());
            while (inStream.available () > 0) {
                outStream.write (inStream.read ());
            }
            inStream.close ();
            outStream.close ();
        } catch (FileNotFoundException fnfe) {
            fnfe.printStackTrace ();
        } catch (IOException ioe) {
            ioe.printStackTrace ();
        }
        forw = "../sendDoc.jsp";
        request.setAttribute ("contentType", context.getMimeType (path + myFile.getName ()));
        request.setAttribute ("text", descrizione);
        request.setAttribute ("path", path + myFile.getName ());
        request.setAttribute ("size", Long.toString (myFile.length ()) + " Bytes");
        RequestDispatcher rd = request.getRequestDispatcher (forw);
        rd.forward (request, response);
    } catch (Exception e) {
        e.printStackTrace ();
    }
}

Function 2:
public static void writeToPetrify (TransitionSystem ts, Writer bw) throws IOException {
    File temp = new File ("_temp");
    BufferedWriter tw = new BufferedWriter (new FileWriter (temp));
    BufferedReader tr = new BufferedReader (new FileReader (temp));
    HashSet < ModelGraphVertex > sources = new HashSet < ModelGraphVertex > ();
    HashSet < ModelGraphVertex > dests = new HashSet < ModelGraphVertex > ();
    ArrayList transitions = ts.getEdges ();
    HashSet < String > events = new HashSet < String > ();
    for (int i = 0;
    i < transitions.size (); i ++) {
        TransitionSystemEdge transition = (TransitionSystemEdge) transitions.get (i);
        events.add (replaceBadSymbols (transition.getIdentifier ()));
        sources.add (transition.getSource ());
        dests.add (transition.getDest ());
        if (ts.getStateNameFlag () == TransitionSystem.ID) {
            tw.write ("s" + transition.getSource ().getId () + " ");
            tw.write (replaceBadSymbols (transition.getIdentifier ()) + " ");
            tw.write ("s" + transition.getDest ().getId () + "\n");
        } else {
            tw.write (replaceBadSymbols (transition.getSource ().getIdentifier ()) + " ");
            tw.write (replaceBadSymbols (transition.getIdentifier ()) + " ");
            tw.write (replaceBadSymbols (transition.getDest ().getIdentifier ()) + "\n");
        }
    }
    tw.close ();
    bw.write (".model " + ts.getName ().replaceAll (" ", "_") + "\n");
    bw.write (".dummy ");
    Iterator it = events.iterator ();
    while (it.hasNext ()) bw.write (it.next () + " ");

    bw.write ("\n");
    bw.write (".state graph" + "\n");
    int c;
    while ((c = tr.read ()) != - 1) bw.write (c);

    tr.close ();
    temp.delete ();
    for (ModelGraphVertex dest : dests) {
        if (sources.contains (dest)) {
            sources.remove (dest);
        }
    }
    ModelGraphVertex source = sources.isEmpty () ? null : sources.iterator ().next ();
    if (ts.getStateNameFlag () == TransitionSystem.ID) {
        if (! ts.hasExplicitEnd ()) bw.write (".marking {s0}" + "\n");
        else bw.write (".marking {s" + source.getId () + "}\n");

    } else if (source != null) {
        bw.write (".marking {" + replaceBadSymbols (source.getIdentifier ()) + "}\n");
    }

    bw.write (".end");
}