本文整理了Java中net.roboconf.core.utils.Utils.copyStreamSafely()
方法的一些代码示例,展示了Utils.copyStreamSafely()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.copyStreamSafely()
方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:copyStreamSafely
[英]Copies the content from in into os.
This method closes the input stream. os does not need to be closed.
[中]将内容从中复制到操作系统中。
此方法关闭输入流。操作系统不需要关闭。
代码示例来源:origin: roboconf/roboconf-platform
/**
* Reads the content of an URL (assumed to be text content).
* @param url an URL
* @return a non-null string
* @throws IOException
* @throws URISyntaxException
*/
public static String readUrlContent( String url )
throws IOException, URISyntaxException {
InputStream in = null;
try {
URI uri = UriUtils.urlToUri( url );
in = uri.toURL().openStream();
ByteArrayOutputStream os = new ByteArrayOutputStream();
Utils.copyStreamSafely( in, os );
return os.toString( "UTF-8" );
} finally {
closeQuietly( in );
}
}
代码示例来源:origin: net.roboconf/roboconf-doc-generator
@Override
protected File writeFileContent(String fileContent) throws IOException {
// Load the template
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream in = getClass().getResourceAsStream( "/fop.tpl" );
Utils.copyStreamSafely( in, out );
//Copy the header in outputDirectory
InputStream h = getClass().getResourceAsStream( "/roboconf.jpg" );
File imgFile = new File( this.outputDirectory, "header.jpg" );
Utils.copyStream( h, imgFile );
// Create the target directory
File targetFile = new File( this.outputDirectory, "index.fo" );
Utils.createDirectory( targetFile.getParentFile());
// Write the main file
String toWrite = out.toString( "UTF-8" )
.replace( TITLE_MARKUP, this.applicationTemplate.getName())
.replace( CONTENT_MARKUP, fileContent )
.replace( "header.jpg", this.outputDirectory.getAbsolutePath() + "/header.jpg" )
.replace( "png/", this.outputDirectory.getAbsolutePath() + "/png/" )
.replaceAll( "\n{3,}", "\n\n" );
Utils.writeStringInto( toWrite, targetFile );
return targetFile;
}
代码示例来源:origin: roboconf/roboconf-platform
@Override
protected File writeFileContent(String fileContent) throws IOException {
// Load the template
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream in = getClass().getResourceAsStream( "/fop.tpl" );
Utils.copyStreamSafely( in, out );
//Copy the header in outputDirectory
InputStream h = getClass().getResourceAsStream( "/roboconf.jpg" );
File imgFile = new File( this.outputDirectory, "header.jpg" );
Utils.copyStream( h, imgFile );
// Create the target directory
File targetFile = new File( this.outputDirectory, "index.fo" );
Utils.createDirectory( targetFile.getParentFile());
// Write the main file
String toWrite = out.toString( "UTF-8" )
.replace( TITLE_MARKUP, this.applicationTemplate.getName())
.replace( CONTENT_MARKUP, fileContent )
.replace( "header.jpg", this.outputDirectory.getAbsolutePath() + "/header.jpg" )
.replace( "png/", this.outputDirectory.getAbsolutePath() + "/png/" )
.replaceAll( "\n{3,}", "\n\n" );
Utils.writeStringInto( toWrite, targetFile );
return targetFile;
}
代码示例来源:origin: roboconf/roboconf-platform
InputStream in = TranslationBundle.class.getResourceAsStream( "/" + lang + ".json" );
ByteArrayOutputStream os = new ByteArrayOutputStream();
Utils.copyStreamSafely( in, os );
String content = os.toString( "UTF-8" );
代码示例来源:origin: roboconf/roboconf-platform
Utils.copyStreamSafely( url.openStream(), os );
代码示例来源:origin: net.roboconf/roboconf-doc-generator
Utils.copyStreamSafely( in, out );
代码示例来源:origin: roboconf/roboconf-platform
Utils.copyStreamSafely( in, out );
代码示例来源:origin: roboconf/roboconf-platform
/**
* Creates a simple project for Roboconf.
* @param targetDirectory the directory into which the Roboconf files must be copied
* @param creationBean the creation properties
* @throws IOException if something went wrong
*/
private static void createSimpleProject( File targetDirectory, CreationBean creationBean )
throws IOException {
// Create the directory structure
String[] directoriesToCreate = creationBean.isReusableRecipe() ? RR_DIRECTORIES : ALL_DIRECTORIES;
for( String s : directoriesToCreate ) {
File dir = new File( targetDirectory, s );
Utils.createDirectory( dir );
}
// Create the descriptor
InputStream in = ProjectUtils.class.getResourceAsStream( "/application-skeleton.props" );
ByteArrayOutputStream out = new ByteArrayOutputStream();
Utils.copyStreamSafely( in, out );
String tpl = out.toString( "UTF-8" )
.replace( TPL_NAME, creationBean.getProjectName())
.replace( TPL_VERSION, creationBean.getProjectVersion())
.replace( TPL_DESCRIPTION, creationBean.getProjectDescription());
// Create the rest of the project
completeProjectCreation( targetDirectory, tpl, creationBean );
}
代码示例来源:origin: net.roboconf/roboconf-agent
ByteArrayOutputStream os = new ByteArrayOutputStream();
Utils.copyStreamSafely( in, os );
String ip = os.toString( "UTF-8" );
if(! AgentUtils.isValidIP( ip )) {
os = new ByteArrayOutputStream();
Utils.copyStreamSafely( in, os );
ip = os.toString( "UTF-8" );
代码示例来源:origin: roboconf/roboconf-platform
@Test
public void testCopyStreamSafely() throws Exception {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ByteArrayInputStream in = new ByteArrayInputStream( "toto".getBytes( "UTF-8" ));
Utils.copyStreamSafely( in, os );
Assert.assertEquals( "toto", os.toString( "UTF-8" ));
}
代码示例来源:origin: roboconf/roboconf-platform
Utils.copyStreamSafely( in, out );
String tpl = out.toString( "UTF-8" )
.replace( TPL_NAME, creationBean.getProjectName())
Utils.copyStreamSafely( in, out );
tpl = out.toString( "UTF-8" )
.replace( TPL_NAME, creationBean.getProjectName())
内容来源于网络,如有侵权,请联系作者删除!