本文整理汇总了Java中com.ibm.commons.util.io.StreamUtil类的典型用法代码示例。如果您正苦于以下问题:Java StreamUtil类的具体用法?Java StreamUtil怎么用?Java StreamUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StreamUtil类属于com.ibm.commons.util.io包,在下文中一共展示了StreamUtil类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadLibrary
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public String loadLibrary(String libName) throws InterpretException {
String result = null;
if (_libs.containsKey(libName)) {
InputStream is = null;
try {
is = getClass().getClassLoader().getResourceAsStream(_libs.get(libName));
result = StreamUtil.readString(is);
} catch (IOException ex) {
throw new InterpretException(ex);
} finally {
try {
is.close();
} catch (Exception e) {
}
}
}
return result;
}
开发者ID:OpenNTF,项目名称:BuildAndTestPattern4Xpages,代码行数:19,代码来源:StarterFactory.java
示例2: createFeatureJar
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
protected void createFeatureJar(final IProject project) throws Exception {
JarOutputStream jar = null;
InputStream is = null;
try {
String directory = _outputDir + "/features/"; // $NON-NLS-1$
Utils.createDirectory(directory);
// Create the Jar
jar = new JarOutputStream(new FileOutputStream(directory + _projectDef.name + ".feature_" + _projectDef.version + ".jar")); // $NON-NLS-1$ $NON-NLS-2$
JarEntry entry = new JarEntry("feature.xml"); // $NON-NLS-1$
jar.putNextEntry(entry);
String contents = getResourceFile(FEATURE_RES);
is = new ByteArrayInputStream(contents.getBytes("UTF-8")); // $NON-NLS-1$
Utils.writeJarEntry(jar, is);
} catch (Exception e) {
throw new Exception("Error creating Feature JAR", e); // $NLX-JdbcPluginGenerator.ErrorcreatingFeatureJar-1$
} finally {
StreamUtil.close(is);
if (jar != null) {
jar.close();
}
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:25,代码来源:JdbcPluginGenerator.java
示例3: copyFilesIntoProject
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public static void copyFilesIntoProject(final IProject project, final String folder, final List<String> fileList) throws Exception {
try {
for (String file : fileList) {
FileInputStream fis = new FileInputStream(file);
try {
String libFile = new File(file).getName();
IFile libFileProj = project.getFile(folder + "/" + libFile);
libFileProj.create(fis, true, null);
} finally {
StreamUtil.close(fis);
}
}
} catch (Exception e) {
throw new Exception("Could not copy JARs into project", e); // $NLX-ProjectUtils.Couldnotcopyjarsintoproject-1$
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:17,代码来源:ProjectUtils.java
示例4: copyResource
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public void copyResource(String dir, String resourceName) throws IOException {
String res = "com/ibm/xsp/eclipse/tools/resources/"+resourceName;
InputStream is = getClass().getClassLoader().getResourceAsStream(res);
if(is!=null) {
try {
File d = new File(baseDirectory,dir);
d.mkdirs();
int pos = resourceName.lastIndexOf('/');
if(pos>=0) {
resourceName = resourceName.substring(pos+1);
}
OutputStream os = new FileOutputStream(new File(d,resourceName));
try {
StreamUtil.copyStream(is,os);
} finally {
os.close();
}
}
finally {
is.close();
}
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:24,代码来源:MarkupGenerator.java
示例5: copyResource
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
private void copyResource(ZipInputStream zin, ZipEntry ze) throws IOException {
String resourcePath = ze.getName();
String targetFileName = StringUtil.replace(resourcePath, '/', File.separatorChar);
File targetFile = new File(installDirectory,targetFileName);
File targetDir = targetFile.getParentFile();
targetDir.mkdirs();
// Add it to the file list
writer.write(resourcePath);
writer.newLine();
OutputStream os = new FileOutputStream(targetFile);
try {
StreamUtil.copyStream(zin, os);
} finally {
os.close();
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:19,代码来源:ResourceInstaller.java
示例6: flush
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
@Override
public void flush() throws IOException {
if (!streamOpened) {
this.createEncoderOutputStream();
streamOpened = true;
}
this.finish();
if (!preventCache) {
httpServletResponse.setContentLength((int)byteStreamCache.getLength());
// And copy the entire content
InputStream is = byteStreamCache.getInputStream();
OutputStream out = httpServletResponse.getOutputStream();
StreamUtil.copyStream(is, out);
out.flush();
byteStreamCache.clear();
}
outputStream.flush();
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:20,代码来源:DasHttpResponseWrapper.java
示例7: getUsingDocument
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
@Override
public UsingDocument getUsingDocument(final boolean create) {
Document doc = database_.getDocumentByID(USING_NOTE);
if (doc != null) {
return new UsingDocument(doc);
} else if (create) {
try {
InputStream is = AboutDocument.class.getResourceAsStream("/org/openntf/domino/design/impl/dxl_helpusingdocument.xml");
String dxl = StreamUtil.readString(is);
is.close();
DxlImporter importer = getAncestorSession().createDxlImporter();
importer.setDesignImportOption(DxlImporter.DesignImportOption.REPLACE_ELSE_CREATE);
importer.setReplicaRequiredForReplaceOrUpdate(false);
importer.importDxl(dxl, database_);
doc = database_.getDocumentByID(USING_NOTE);
return new UsingDocument(doc);
} catch (IOException e) {
DominoUtils.handleException(e);
}
}
return null;
}
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:23,代码来源:DatabaseDesign.java
示例8: createSiteXml
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
protected void createSiteXml() throws Exception {
FileOutputStream fos = null;
try {
Utils.createDirectory(_outputDir);
String contents = getResourceFile(SITE_RES);
File f = new File(_outputDir, "site.xml"); // $NON-NLS-1$
fos = new FileOutputStream(f);
fos.write(contents.getBytes("UTF-8")); // $NON-NLS-1$
} catch (Exception e) {
throw new Exception("Error creating \"site.xml\"", e); // $NLX-JdbcPluginGenerator.Errorcreatingsitexml-1$
} finally {
StreamUtil.close(fos);
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:15,代码来源:JdbcPluginGenerator.java
示例9: writeFile
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public static void writeFile(final String name, final IContainer container, final String content) throws Exception {
InputStream is = null;
try {
IFile file = container.getFile(new Path(name));
is = new ByteArrayInputStream(content.getBytes(file.getCharset()));
file.create(is, true, null);
} catch (Exception e) {
String msg = StringUtil.format("Could not create the file \"{0}\"", name); // $NLX-ProjectUtils.Couldnotcreatethefile0-1$
throw new Exception(msg, e);
} finally {
StreamUtil.close(is);
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:14,代码来源:ProjectUtils.java
示例10: getFileContents
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public static String getFileContents(final Bundle bundle, final String resName) throws Exception {
URL resURL = bundle.getResource(resName);
String content;
InputStream is = resURL.openStream();
try {
java.util.Scanner s = new java.util.Scanner(is, "UTF-8").useDelimiter("\\A"); // $NON-NLS-1$ $NON-NLS-2$
content = s.hasNext() ? s.next() : "";
} finally {
StreamUtil.close(is);
}
return content;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:15,代码来源:Utils.java
示例11: writeJarEntry
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public static void writeJarEntry(final JarOutputStream jar, final InputStream is) throws Exception {
BufferedInputStream bis = new BufferedInputStream(is);
try {
byte[] buf = new byte[8192];
while (true) {
int count = bis.read(buf);
if (count == -1)
break;
jar.write(buf, 0, count);
}
jar.closeEntry();
} finally {
StreamUtil.close(bis);
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:16,代码来源:Utils.java
示例12: flushStream
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public void flushStream() throws ServiceException {
if(streamFlushed) {
return;
}
streamFlushed = true;
if(os!=null) {
try {
os.flush();
if(bs!=null) {
// Emit the GZIP header if necessary
if(os instanceof GZIPOutputStream) {
((GZIPOutputStream)os).finish();
httpResponse.setHeader(HEADER_CONTENT_ENCODING, ENCODING_GZIP);
}
// We have the length from the buffer
httpResponse.setContentLength((int)bs.getLength());
// And copy the entire content
InputStream is = bs.getInputStream();
OutputStream out = getHttpResponse().getOutputStream();
StreamUtil.copyStream(is, out);
out.flush();
} else {
// Finish the GZIP stream
if(os instanceof GZIPOutputStream) {
((GZIPOutputStream)os).finish();
httpResponse.setHeader(HEADER_CONTENT_ENCODING, ENCODING_GZIP);
}
}
} catch(IOException ex) {
throw new ServiceException(ex,"Error when sending data to the client"); // $NLX-HttpServiceEngine.Errorwhensendingdatatotheclient-1$
}
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:36,代码来源:HttpServiceEngine.java
示例13: loadResourceFactory
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public IJdbcResourceFactory loadResourceFactory(String name) throws ResourceFactoriesException {
InputStream is = getFileContent(name);
try {
return loadJDBCConnection(is, name);
} finally {
StreamUtil.close(is);
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:9,代码来源:AbstractFileJdbcProvider.java
示例14: readConfig
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Map<String, String> readConfig(String[][] extraConfig) {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
// ResourceBundle bundle = ResourceBundle.getBundle("com.ibm.xsp.test.framework.config");
HashMap<String, String> config = new HashMap<String, String>();
try {
URL url = contextClassLoader.getResource("com/ibm/xsp/test/framework/config.properties");
if (url != null) {
String pathToConfig = url.getPath();
if (StringUtil.isNotEmpty(pathToConfig)) {
if (pathToConfig.contains("com.ibm.xsp.test.framework"))
throw new RuntimeException("The first detected config.properties file is in the ...test.framework plugin (at "
+ url.getPath()
+ "). Please instead add a config.properties file in your library test project, "
+ "and rearrange the test project .classpath file to search in the test project first, "
+ "before the plugin dependancies.");
}
}
InputStream in = url.openStream();
try{
Properties props = new Properties();
props.load(in);
config.putAll((Map)props);
}finally{
StreamUtil.close(in);
}
} catch (IOException e1) {
e1.printStackTrace();
throw new RuntimeException(e1.toString(), e1);
}
if( null != extraConfig && extraConfig.length > 0){
for (String[] keyToValue : extraConfig) {
config.put(keyToValue[0], keyToValue[1]);
}
}
return config;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:40,代码来源:ConfigUtil.java
示例15: processToStream
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public void processToStream(RestServiceEngine engine, FileHelper fh) {// byte[]
// byteFile)
// {
try {
InputStream is = getFileSteam(fh);
OutputStream os = engine.getHttpResponse().getOutputStream();
// os.write(byteFile);
StreamUtil.copyStream(is, os);
os.close();
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:OpenNTF,项目名称:myWebGate-Scrum,代码行数:16,代码来源:FileService.java
示例16: instantiateDb
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
private static String instantiateDb(final String basename) throws IOException {
File dbFile = File.createTempFile(basename, ".nsf"); //$NON-NLS-1$
Platform.getInstance().log("{0} location is {1}", basename, dbFile.getAbsolutePath()); //$NON-NLS-1$
FileOutputStream fos = new FileOutputStream(dbFile);
InputStream is = AllTests.class.getResourceAsStream("/" + basename + ".nsf"); //$NON-NLS-1$ //$NON-NLS-2$
StreamUtil.copyStream(is, fos);
fos.flush();
StreamUtil.close(fos);
StreamUtil.close(is);
return dbFile.getAbsolutePath();
}
开发者ID:jesse-gallagher,项目名称:XPages-Scaffolding,代码行数:12,代码来源:AllTests.java
示例17: getAccessTokenForAuthorizedUser
import com.ibm.commons.util.io.StreamUtil; //导入依赖的package包/类
public void getAccessTokenForAuthorizedUser() throws Exception {
HttpPost method = null;
int responseCode = HttpStatus.SC_OK;
String responseBody = null;
InputStream content = null;
try {
HttpClient client = new DefaultHttpClient();
StringBuffer url = new StringBuffer(2048);
url.append(getAccessTokenURL()).append("?");
url.append(BASECAMP_OAUTH2_TYPE).append('=').append(getApplicationType());
url.append('&');
url.append(BASECAMP_OAUTH2_REDIRECTURI).append('=').append(URLEncoder.encode(getClient_uri(), "UTF-8"));
url.append('&');
url.append(Configuration.OAUTH2_CLIENT_ID).append('=').append(URLEncoder.encode(getConsumerKey(), "UTF-8"));
url.append('&');
url.append(Configuration.OAUTH2_CLIENT_SECRET).append('=').append(URLEncoder.encode(getConsumerSecret(), "UTF-8"));
url.append('&');
url.append(Configuration.OAUTH2_CODE).append('=').append(URLEncoder.encode(getAuthorization_code(), "UTF-8"));
method = new HttpPost(url.toString());
HttpResponse httpResponse =client.execute(method);
responseCode = httpResponse.getStatusLine().getStatusCode();
content = httpResponse.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
try {
responseBody = StreamUtil.readString(reader);
} finally {
StreamUtil.close(reader);
}
} catch (Exception e) {
throw new OAuthException(e, "getAccessToken failed with Exception: <br>" + e);
} finally {
if(content != null) {
content.close();
}
}
if (responseCode != HttpStatus.SC_OK) {
getAccessTokenForAuthorizedUsingPOST();
return;
// if (responseCode == HttpStatus.SC_UNAUTHORIZED) {
// throw new Exception("getAccessToken failed with Response Code: Unauthorized (401),<br>Msg: " + responseBody);
// } else if (responseCode == HttpStatus.SC_BAD_REQUEST) {
// throw new Exception("getAccessToken failed with Response Code: Bad Request (400),<br>Msg: " + responseBody);
// } else if (responseCode == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
// throw new Exception("getAccessToken failed with Response Code: Internal Server error (500),<br>Msg: " + responseBody);
// } else {
// throw new Exception("getAccessToken failed with Response Code: (" + responseCode + "),<br>Msg: " + responseBody);
// }
} else {
setOAuthData(responseBody); //save the returned data
}
}
开发者ID:sbasegmez,项目名称:ic14demos,代码行数:56,代码来源:BaseCampOAuth2Handler.java
注:本文中的com.ibm.commons.util.io.StreamUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论