This is probably very easy to solve, but I am stuck on this for a while now. I got a while loop which I use to write data. I want to write the data from the while loop to a String.
public void dumpPart(Part p) throws Exception {
    InputStream is = p.getInputStream();
    if (!(is instanceof BufferedInputStream)) {
        is = new BufferedInputStream(is);
    }
    int c;
    System.out.println("Message: ");
    while ((c = is.read()) != -1) {
        System.out.write(c);  //I want to write this data to a String.
    }
    sendmail.VerstuurEmail(mpMessage, kenmerk);
}
Solved:
public void dumpPart(Part p) throws Exception {
    InputStream is = p.getInputStream();
    if (!(is instanceof BufferedInputStream)) {
        is = new BufferedInputStream(is);
    }
    int c;
     final StringWriter sw = new StringWriter();
    System.out.println("Message: ");
    while ((c = is.read()) != -1) {
        sw.write(c);
    }
    mpMessage = sw.toString();;
    sendmail.VerstuurEmail(mpMessage, kenmerk);
}
Thanks for your help.
 
     
     
     
     
     
     
    