Code example for StringWriter

Methods: flushtoString

0
	@Test 
	public void objectSerializationTest(){ 
		try { 
			ConciseBoundedDescriptionGenerator modelGen = new ConciseBoundedDescriptionGeneratorImpl(SparqlEndpoint.getEndpointDBpediaLiveAKSW());
			Model model = modelGen.getConciseBoundedDescription("http://dbpedia.org/resource/Berlin", 2);
			StringWriter sw = new StringWriter();
			model.write(sw, "TURTLE");
			sw.flush();
			String modelString = sw.toString();
			File f = new File("model.txt");
			Files.writeObjectToFile(modelString, f);
			long startTime = System.currentTimeMillis();
			modelString = (String) Files.readObjectfromFile(f);
			model = ModelFactory.createDefaultModel();
			model.read(new StringReader(modelString), null, "TURTLE");
			System.out.println(System.currentTimeMillis()-startTime);
			 
			 
			ExtractionDBCache cache = new ExtractionDBCache("cache");
		} catch (Exception e) {
Connect your IDE to all the code out there  Get Codota for Java