public static String getText(final JTextPane tp, final F0<Boolean> interrupted) {
	
		Document doc = tp.getDocument();
	    try {
			int length = doc.getLength();
			EditorKit editorKit = tp.getUI().getEditorKit(tp);
	
		    StringWriter out = new StringWriter();
			// 524288
			// 262144
			int index = 0;
			while (length > 0) {
				if (interrupted.e())return null;
				
				int l;
				if (length > 524288) {
					l = 524288;
				} else {
					l = length;
				}
				editorKit.write(out, doc, index, l);
				length -= l;
				index+=l;
				
			}
			return out.toString();
	    } catch (BadLocationException e) {
			throw new RuntimeException(e);
	    } catch (IOException e) {
			throw new RuntimeException(e);
		}
	}