Package javax.tools

Examples of javax.tools.FileObject.openInputStream()


            os.close();

            try {
              fo = processingEnv.getFiler().getResource(StandardLocation.SOURCE_OUTPUT, packageName,
                  fileName + ".js");
              InputStream is = fo.openInputStream();
              is.close();
            } catch (FileNotFoundException e) {
              String subClassCode = generateSubclassCode(modelClass, outputConfig);
              fo = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, packageName,
                  fileName + ".js");
View Full Code Here


    protected InputStream getInputStream(String filename, boolean loadingPersistenceXML) {
        InputStream inputStream = null;
       
        try {
            FileObject fileObject = getFileObject(filename, processingEnv);
            inputStream = fileObject.openInputStream();
        } catch (Exception ioe) {
            // If we can't find the persistence.xml from the class output
            // we'll try from the current directory using regular IO.
            try {
                inputStream = new FileInputStream(filename);
View Full Code Here

    InputStream ormStream;
    try {
      FileObject fileObject = context.getProcessingEnvironment()
          .getFiler()
          .getResource( StandardLocation.CLASS_OUTPUT, pkg, name );
      ormStream = fileObject.openInputStream();
    }
    catch ( IOException e1 ) {
      // TODO - METAGEN-12
      // unfortunately, the Filer.getResource API seems not to be able to load from /META-INF. One gets a
      // FilerException with the message with "Illegal name /META-INF". This means that we have to revert to
View Full Code Here

  @Override
  public Timestamped<Resource> resolveResource(Path.Absolute path) {
    FileObject resource = owner.application.resolveResource(path);
    if (resource != null) {
      try {
        byte[] bytes = Tools.bytes(resource.openInputStream());
        long lastModified = resource.getLastModified();
        return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset()));
      }
      catch (Exception e) {
        env.info("Could not get resource content " + path.getCanonical(), e);
View Full Code Here

    // Try to get state or create new one
    if (state == null) {
      InputStream in = null;
      try {
        FileObject file = getContext().getResource(StandardLocation.SOURCE_OUTPUT, "juzu", "metamodel.ser");
        in = file.openInputStream();
        ObjectInputStream ois = new ObjectInputStream(in);
        state = (MetaModelState<P, M>)ois.readObject();
        log.info("Loaded model from " + file.toUri());
      }
      catch (Exception e) {
View Full Code Here

        if (t.length() > 0) {
          String s = null;
          InputStream in = null;
          try {
            FileObject file = context.getResource(StandardLocation.SOURCE_OUTPUT, "juzu", "processor.log");
            in = file.openInputStream();
            s = Tools.read(in, Tools.UTF_8);
          }
          catch (Exception ignore) {
          }
          finally {
View Full Code Here

        if (count++ == 0) {
          try {
            ProcessingContext ctx = new ProcessingContext(processingEnv);
            ElementHandle.Package pkg = ElementHandle.Package.create(ctx.getPackageElement("compiler.dot.foo"));
            FileObject file = ctx.resolveResourceFromSourcePath(pkg, FileKey.newName("compiler.dot.foo", "a.b.txt"));
            InputStream in = file.openInputStream();
            FileObject o = ctx.createResource(StandardLocation.CLASS_OUTPUT, FileKey.newName("compiler.dot.foo", "a.b.css"));
            OutputStream out = o.openOutputStream();
            Tools.copy(in, out);
            Tools.safeClose(in);
            Tools.safeClose(out);
View Full Code Here

      if (roundEnv.processingOver()) {

        // Read an existing resource
        FileObject foo = processingContext.getResource(location, "", "foo.txt");
        assertNotNull(foo);
        String s = Tools.read(foo.openInputStream());
        assertEquals("foo_value", s);

        // Now we overwrite the resource
        foo = processingContext.createResource(location, "", "foo.txt");
        OutputStream out = foo.openOutputStream();
View Full Code Here

    protected InputStream getInputStream(String filename, boolean loadingPersistenceXML) {
        InputStream inputStream = null;
       
        try {
            FileObject fileObject = getFileObject(filename, processingEnv);
            inputStream = fileObject.openInputStream();
        } catch (IOException ioe) {
            // If we can't find the persistence.xml from the class output
            // we'll try from the current directory using regular IO.
            try {
                inputStream = new FileInputStream(filename);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.