/** * @return The full binary content of this URL's stream. */ public static byte[] getBinaryContent( @This URL thiz ) { try( InputStream stream = thiz.openStream() ) { return StreamUtil.getContent( stream ); } catch( IOException e ) { throw new RuntimeException( e ); } }
public static String getContent( IFile file ) { if( file != null ) { try( InputStream inputStream = file.openInputStream() ) { return StreamUtil.getContent( new InputStreamReader( inputStream ) ); //.replace( "\r\n", "\n" ); } catch( Exception e ) { throw new RuntimeException( e ); } } return null; }
private String assignContent() { if( _file != null ) { try( InputStream inputStream = _file.openInputStream() ) { return StreamUtil.getContent( new InputStreamReader( inputStream ) ); //.replace( "\r\n", "\n" ); } catch( Exception e ) { throw new RuntimeException( e ); } } return null; } }
private String assignContent() { if( _file != null ) { try( InputStream inputStream = _file.openInputStream() ) { return StreamUtil.getContent( new InputStreamReader( inputStream ) ); //.replace( "\r\n", "\n" ); } catch( Exception e ) { throw new RuntimeException( e ); } } return null; } }
private String getSource( Model model ) { try { return StreamUtil.getContent( new InputStreamReader( model.getFile().openInputStream() ) ); } catch( IOException ioe ) { throw new RuntimeException( ioe ); } }
private String getSource( Model model ) { try { return StreamUtil.getContent( new InputStreamReader( model.getFile().openInputStream() ) ); } catch( IOException ioe ) { throw new RuntimeException( ioe ); } }
private int findOffset( IFile file, int lineNum, int column ) { try { int offset = 0; String content = StreamUtil.getContent( new InputStreamReader( file.openInputStream() ) ); for( int i = 1; i < lineNum; i++ ) { if( content.length() > offset ) { offset = content.indexOf( '\n', offset ) + 1; } } return offset + column - 1; } catch( IOException e ) { throw new RuntimeException( e ); } }
private void addResourcePaths( File file, Set<String> resourcePath ) { try { String content = StreamUtil.getContent( new FileReader( file ) ); int index = content.indexOf( RESOURCE_ROOTS ); if( index >= 0 ) { int iEol = content.indexOf( '\n', index ); String paths = content.substring( index + RESOURCE_ROOTS.length(), iEol ); paths = paths.trim(); for( StringTokenizer tokenizer = new StringTokenizer( paths, File.pathSeparator ); tokenizer.hasMoreTokens(); ) { String path = tokenizer.nextToken(); if( new File( path ).isDirectory() ) { resourcePath.add( path ); } } } } catch( IOException e ) { throw new RuntimeException( e ); } }
static Set<String> getExtendedTypes( IFile file ) { Objects.requireNonNull( file ); String content; try { content = StreamUtil.getContent( new InputStreamReader( file.openInputStream() ) ); } catch( IOException e ) { throw new RuntimeException( e ); } Set<String> extendedTypes = new HashSet<>(); for( StringTokenizer tokenizer = new StringTokenizer( content, "\r\n" ); tokenizer.hasMoreTokens(); ) { String line = tokenizer.nextToken(); StringTokenizer lineTokenizer = new StringTokenizer( line, "|" ); String extended = lineTokenizer.nextToken(); extendedTypes.add( extended ); } return extendedTypes; }
static Set<String> getExtendedTypes( IFile file ) { Objects.requireNonNull( file ); String content; try { content = StreamUtil.getContent( new InputStreamReader( file.openInputStream() ) ); } catch( IOException e ) { throw new RuntimeException( e ); } Set<String> extendedTypes = new HashSet<>(); for( StringTokenizer tokenizer = new StringTokenizer( content, "\r\n" ); tokenizer.hasMoreTokens(); ) { String line = tokenizer.nextToken(); StringTokenizer lineTokenizer = new StringTokenizer( line, "|" ); String extended = lineTokenizer.nextToken(); extendedTypes.add( extended ); } return extendedTypes; }
/** * @return The full text content of this URL's stream. */ public static String getTextContent( @This URL thiz ) { try( Reader reader = StreamUtil.getInputStreamReader( thiz.openStream() ) ) { return StreamUtil.getContent( reader ); } catch( IOException e ) { throw new RuntimeException( e ); } }
private String extractPackageName( String file ) { try { String source = StreamUtil.getContent( new FileReader( file ) ); int iPkg = source.indexOf( "package" ); if( iPkg >= 0 ) { int iEol = source.indexOf( '\n', iPkg ); if( iEol > iPkg ) { String pkg = source.substring( iPkg + "package".length(), iEol ).trim(); for( StringTokenizer tokenizer = new StringTokenizer( pkg, "." ); tokenizer.hasMoreTokens(); ) { String part = tokenizer.nextToken(); if( !ManClassUtil.isJavaIdentifier( part ) ) { return null; } } return pkg; } } return null; } catch( IOException e ) { throw new RuntimeException( e ); } }
private String getSource( JCDiagnostic jcDiagnostic ) { if( _source == null ) { try { Reader reader = jcDiagnostic.getSource().openReader( true ); _source = StreamUtil.getContent( reader ); } catch( IOException e ) { throw new RuntimeException( e ); } } return _source; } }
@Override public CharSequence getCharContent( boolean ignoreEncodingErrors ) throws IOException { if( _content != null ) { return _content; } Path file = PathUtil.create( uri ); try( BufferedReader reader = PathUtil.createReader( file ) ) { return _content = StreamUtil.getContent( reader ); } }
private static Class defineClass( ClassLoader cl, String fqn ) throws IOException { InputStream stream = cl.getResourceAsStream( fqn ); byte[] bytes = StreamUtil.getContent( stream ); ClassLoader parent = (ClassLoader)Array.get( ReflectUtil.field( cl, "myParents" ).get(), 0 ); return (Class)ReflectUtil.method( parent, "defineClass", byte[].class, int.class, int.class ).invoke( bytes, 0, bytes.length ); }
return StreamUtil.getContent( in );
String content = StreamUtil.getContent( new InputStreamReader( file.openInputStream() ) ); return content.contains( "@Extension" ) && content.contains( Extension.class.getPackage().getName() ); String content = StreamUtil.getContent( new InputStreamReader( file.openInputStream() ) ); return content.contains( Extension.class.getName().replace( '.', '/' ) );
public Optional<ByteBuffer> read( String name ) throws IOException { Optional<ByteBuffer> buffer = (Optional<ByteBuffer>)ReflectUtil.method( _delegate, "read", String.class ).invoke( name ); if( !buffer.isPresent() ) { Object/*Resource*/ resource = ReflectUtil.method( _ucp, "getResource", String.class, boolean.class ).invoke( name, false ); if( resource != null ) { ByteBuffer bytes = ByteBuffer.wrap( StreamUtil.getContent( (InputStream)ReflectUtil.method( resource, "getInputStream" ).invoke() ) ); buffer = Optional.of( bytes ); } } return buffer; }
private void init() { IFile file = getFile(); if( !file.exists() ) { return; } try { String templateSource = StreamUtil.getContent( new InputStreamReader( file.openInputStream() ) ); templateSource = templateSource.replace( "\r\n", "\n" ); TemplateGen generator = new TemplateGen(); _source = generator.generateCode( getFqn(), templateSource, file.toURI(), file.getName() ); _issues = generator.getIssues(); } catch( IOException e ) { throw new RuntimeException( e ); } }
private void init() { IFile file = getFile(); if( !file.exists() ) { return; } try { String templateSource = StreamUtil.getContent( new InputStreamReader( file.openInputStream() ) ); templateSource = templateSource.replace( "\r\n", "\n" ); TemplateGen generator = new TemplateGen(); _source = generator.generateCode( getFqn(), templateSource, file.toURI(), file.getName() ); _issues = generator.getIssues(); } catch( IOException e ) { throw new RuntimeException( e ); } }