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


Java FileUtils.close方法代码示例

本文整理汇总了Java中org.apache.cassandra.io.util.FileUtils.close方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.close方法的具体用法?Java FileUtils.close怎么用?Java FileUtils.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.io.util.FileUtils的用法示例。


在下文中一共展示了FileUtils.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: gceApiCall

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String gceApiCall(String url) throws IOException, ConfigurationException
{
    // Populate the region and zone by introspection, fail if 404 on metadata
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    DataInputStream d = null;
    try
    {
        conn.setRequestMethod("GET");
 conn.setRequestProperty("Metadata-Flavor", "Google");
        if (conn.getResponseCode() != 200)
            throw new ConfigurationException("GoogleCloudSnitch was unable to execute the API call. Not a gce node?");

        // Read the information.
        int cl = conn.getContentLength();
        byte[] b = new byte[cl];
        d = new DataInputStream((FilterInputStream) conn.getContent());
        d.readFully(b);
        return new String(b, StandardCharsets.UTF_8);
    }
    finally
    {
        FileUtils.close(d);
        conn.disconnect();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:26,代码来源:GoogleCloudSnitch.java

示例2: awsApiCall

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String awsApiCall(String url) throws IOException, ConfigurationException
{
    // Populate the region and zone by introspection, fail if 404 on metadata
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    DataInputStream d = null;
    try
    {
        conn.setRequestMethod("GET");
        if (conn.getResponseCode() != 200)
            throw new ConfigurationException("Ec2Snitch was unable to execute the API call. Not an ec2 node?");

        // Read the information. I wish I could say (String) conn.getContent() here...
        int cl = conn.getContentLength();
        byte[] b = new byte[cl];
        d = new DataInputStream((FilterInputStream) conn.getContent());
        d.readFully(b);
        return new String(b, StandardCharsets.UTF_8);
    }
    finally
    {
        FileUtils.close(d);
        conn.disconnect();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:Ec2Snitch.java

示例3: awsApiCall

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String awsApiCall(String url) throws IOException, ConfigurationException
{
    // Populate the region and zone by introspection, fail if 404 on metadata
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    DataInputStream d = null;
    try
    {
        conn.setRequestMethod("GET");
        if (conn.getResponseCode() != 200)
            throw new ConfigurationException("Ec2Snitch was unable to execute the API call. Not an ec2 node?");

        // Read the information. I wish I could say (String) conn.getContent() here...
        int cl = conn.getContentLength();
        byte[] b = new byte[cl];
        d = new DataInputStream((FilterInputStream) conn.getContent());
        d.readFully(b);
        return new String(b, Charsets.UTF_8);
    }
    finally
    {
        FileUtils.close(d);
        conn.disconnect();
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:Ec2Snitch.java

示例4: close

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void close()
{
    try
    {
        sstable.close();
        if (isClosed.compareAndSet(false, true))
            FileUtils.close(dfile, ifile);
    }
    catch (IOException e)
    {
        sstable.markSuspect();
        throw new CorruptSSTableException(e, sstable.getFilename());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:15,代码来源:BigTableScanner.java

示例5: csQueryMetadata

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
String csQueryMetadata(String url) throws ConfigurationException, IOException
{
    HttpURLConnection conn = null;
    DataInputStream is = null;

    try 
    {
        conn = (HttpURLConnection) new URL(url).openConnection();
    } 
    catch (Exception e) 
    {
        throw new ConfigurationException("CloudstackSnitch cannot query wrong metadata URL: " + url);
    }
    try 
    {
        conn.setRequestMethod("GET");
        if (conn.getResponseCode() != 200) 
        {
            throw new ConfigurationException("CloudstackSnitch was unable to query metadata.");
        }

        int cl = conn.getContentLength();
        byte[] b = new byte[cl];
        is = new DataInputStream(new BufferedInputStream(conn.getInputStream()));
        is.readFully(b);
        return new String(b, StandardCharsets.UTF_8);
    } 
    finally 
    {
        FileUtils.close(is);
        conn.disconnect();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:34,代码来源:CloudstackSnitch.java

示例6: close

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void close()
{
    try
    {
        if (isClosed.compareAndSet(false, true))
            FileUtils.close(dfile, ifile);
    }
    catch (IOException e)
    {
        sstable.markSuspect();
        throw new CorruptSSTableException(e, sstable.getFilename());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:BigTableScanner.java

示例7: close

import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public void close() throws IOException
{
    FileUtils.close(dfile, ifile);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:SSTableScanner.java


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