All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gw.lang.javac.SourceJavaFileObject Maven / Gradle / Ivy

There is a newer version: 1.18.2
Show newest version
package gw.lang.javac;

import gw.util.PathUtil;
import gw.util.StreamUtil;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import javax.tools.SimpleJavaFileObject;

/**
 */
public class SourceJavaFileObject extends SimpleJavaFileObject
{
  public SourceJavaFileObject( URI uri )
  {
    super( uri, Kind.SOURCE );
  }

  public SourceJavaFileObject( String filename )
  {
    super( PathUtil.create( filename ).toUri(), Kind.SOURCE );
  }

  @Override
  public CharSequence getCharContent( boolean ignoreEncodingErrors ) throws IOException
  {
    Path file = PathUtil.create( uri );
    try( BufferedReader reader = PathUtil.createReader( file ) )
    {
      return StreamUtil.getContent( reader );
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy