当前位置: 首页>>代码示例>>Java>>正文


Java IOUtils类代码示例

本文整理汇总了Java中com.alibaba.dubbo.common.utils.IOUtils的典型用法代码示例。如果您正苦于以下问题:Java IOUtils类的具体用法?Java IOUtils怎么用?Java IOUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IOUtils类属于com.alibaba.dubbo.common.utils包,在下文中一共展示了IOUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRouter

import com.alibaba.dubbo.common.utils.IOUtils; //导入依赖的package包/类
public Router getRouter(URL url) {
    try {
        // File URL 转换成 其它Route URL,然后Load
        // file:///d:/path/to/route.js?router=script ==> script:///d:/path/to/route.js?type=js&rule=<file-content>
        String protocol = url.getParameter(Constants.ROUTER_KEY, ScriptRouterFactory.NAME); // 将原类型转为协议
        String type = null; // 使用文件后缀做为类型
        String path = url.getPath();
        if (path != null) {
            int i = path.lastIndexOf('.');
            if (i > 0) {
                type = path.substring(i + 1);
            }
        }
        String rule = IOUtils.read(new FileReader(new File(url.getAbsolutePath())));
        URL script = url.setProtocol(protocol).addParameter(Constants.TYPE_KEY, type).addParameterAndEncoded(Constants.RULE_KEY, rule);
        
        return routerFactory.getRouter(script);
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:FileRouterFactory.java

示例2: joinExchange

import com.alibaba.dubbo.common.utils.IOUtils; //导入依赖的package包/类
public ExchangePeer joinExchange(URL url, ExchangeHandler handler) throws RemotingException {
    ExchangePeer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:17,代码来源:FileExchangeGroup.java

示例3: leave

import com.alibaba.dubbo.common.utils.IOUtils; //导入依赖的package包/类
@Override
public void leave(URL url) throws RemotingException {
    super.leave(url);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        List<String> saves = new ArrayList<String>();
        for (String line : lines) {
            if (full.equals(line)) {
                return;
            }
            saves.add(line);
        }
        IOUtils.appendLines(file, saves.toArray(new String[0]));
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:FileExchangeGroup.java

示例4: join

import com.alibaba.dubbo.common.utils.IOUtils; //导入依赖的package包/类
public Peer join(URL url, ChannelHandler handler) throws RemotingException {
    Peer peer = super.join(url, handler);
    try {
        String full = url.toFullString();
        String[] lines = IOUtils.readLines(file);
        for (String line : lines) {
            if (full.equals(line)) {
                return peer;
            }
        }
        IOUtils.appendLines(file, new String[] {full});
    } catch (IOException e) {
        throw new RemotingException(new InetSocketAddress(NetUtils.getLocalHost(), 0), getUrl().toInetSocketAddress(), e.getMessage(), e);
    }
    return peer;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:17,代码来源:FileGroup.java

示例5: unzip

import com.alibaba.dubbo.common.utils.IOUtils; //导入依赖的package包/类
/**
 * unzip.
 * 
 * @param bytes compressed byte array.
 * @return byte uncompressed array.
 * @throws IOException
 */
public static byte[] unzip(byte[] bytes) throws IOException
{
	UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(bytes);
	UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream();
	InputStream is = new InflaterInputStream(bis);
	try
	{
		IOUtils.write(is, bos);
		return bos.toByteArray();
	}
	finally
	{
		is.close();
		bis.close();
		bos.close();
	}
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:Bytes.java

示例6: getRouter

import com.alibaba.dubbo.common.utils.IOUtils; //导入依赖的package包/类
public Router getRouter(URL url) {
    try {
        // File URL 转换成 其它Route URL,然后Load
        // file:///d:/path/to/route.js?router=script ==> script:///d:/path/to/route.js?type=js&rule=<file-content>
        String protocol = url.getParameter(Constants.ROUTER_KEY, ScriptRouterFactory.NAME); // 将原类型转为协议
        String type = null; // 使用文件后缀做为类型
        String path = url.getPath();
        if (path != null) {
            int i = path.lastIndexOf('.');
            if (i > 0) {
                type = path.substring(i + 1);
            }
        }
        String rule = IOUtils.read(new FileReader(new File(url.getAbsolutePath())));
        URL script = url.setProtocol(protocol).addParameter(Constants.TYPE_KEY, type).addParameterAndEncoded(Constants.RULE_KEY, rule);

        return routerFactory.getRouter(script);
    } catch (IOException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:22,代码来源:FileRouterFactory.java


注:本文中的com.alibaba.dubbo.common.utils.IOUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。