
de.pfabulist.loracle.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of loracle-maven-plugin Show documentation
Show all versions of loracle-maven-plugin Show documentation
maven plugin to check the licenses of all dependencies and possible incompatibilities
package de.pfabulist.loracle;
import de.pfabulist.loracle.buildup.JSONStartup;
import de.pfabulist.unchecked.Unchecked;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
/**
* Copyright (c) 2006 - 2016, Stephan Pfab
* SPDX-License-Identifier: BSD-2-Clause
*/
public class Utils {
public static String getResourceAsString( String res ) {
byte[] buf = new byte[ 3000000 ];
int got = 0;
try( @Nullable InputStream in = JSONStartup.class.getResourceAsStream( res) ) {
if ( in == null ) {
return "";
}
while( true ) {
int once = in.read( buf, got, 3000000 - got );
if( once < 0 ) {
break;
}
got += once;
}
} catch( IOException e ) {
throw Unchecked.u( e );
}
return new String( buf, 0, got, StandardCharsets.UTF_8 );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy