Example usage for org.apache.wicket.util.file File readString

List of usage examples for org.apache.wicket.util.file File readString

Introduction

In this page you can find the example usage for org.apache.wicket.util.file File readString.

Prototype

public String readString() throws IOException 

Source Link

Usage

From source file:com.googlecode.ounit.HtmlFile.java

License:Open Source License

@Override
public Markup getAssociatedMarkup() {
    File f = getFile();

    if (!getFile().canRead()) {
        //return Markup.NO_MARKUP;
        return Markup.of("<wicket:panel></wicket:panel>");
    }/* www  .j a v a 2 s  . c o m*/

    final AppendingStringBuffer sb = new AppendingStringBuffer("<wicket:panel>");
    try {
        sb.append(f.readString());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    sb.append("</wicket:panel>");
    InvalidMarkupFilter.removeInvalidMarkup(sb);

    return MarkupFactory.get().loadMarkup(this, new MarkupResourceStream(new StringResourceStream(sb)), false);
}

From source file:eu.uqasar.util.io.exporter.QProjectJsonWriterTest.java

License:Apache License

@Test
public void testCreateJsonFile() {

    try {// w w  w. j ava2  s  .  com
        File file = writer.createJsonFile(project);
        Assert.assertNotNull(file);
        Assert.assertNotNull(file.getPath());
        Assert.assertTrue(file.isFile());
        logger.info("File created " + file.getAbsolutePath());

        String jsonSource = file.readString();
        logger.info("File content: " + jsonSource);
        // Attempt to parse the file content
        new JsonParser().parse(jsonSource);

    } catch (JsonGenerationException e) {
        e.printStackTrace();
        fail();
    } catch (JsonMappingException e) {
        e.printStackTrace();
        fail();
    } catch (JsonSyntaxException e) {
        e.printStackTrace();
        fail();
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    }
}