Example usage for java.io EOFException printStackTrace

List of usage examples for java.io EOFException printStackTrace

Introduction

In this page you can find the example usage for java.io EOFException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.mbrlabs.mundus.utils.TerrainIO.java

public static Terrain importTerrain(ProjectContext projectContext, Terrain terrain) {
    FloatArray floatArray = new FloatArray();

    String terraPath = FilenameUtils.concat(projectContext.path, terrain.terraPath);
    try (DataInputStream is = new DataInputStream(
            new BufferedInputStream(new GZIPInputStream(new FileInputStream(terraPath))))) {
        while (is.available() > 0) {
            floatArray.add(is.readFloat());
        }//from  www  . java2s. co  m
    } catch (EOFException e) {
        //e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    //Log.debug("Terrain import. floats: " + floatArray.size);

    terrain.heightData = floatArray.toArray();
    terrain.init();
    terrain.update();

    // set default terrain base texture if none is present
    TerrainTexture terrainTexture = terrain.getTerrainTexture();
    if (terrainTexture.getTexture(SplatTexture.Channel.BASE) == null) {
        MTexture base = new MTexture();
        base.setId(-1);
        base.texture = TextureUtils.loadMipmapTexture(Gdx.files.internal("textures/terrain/chess.png"), true);
        terrainTexture.setSplatTexture(new SplatTexture(SplatTexture.Channel.BASE, base));
    }

    // load splat map if available
    SplatMap splatmap = terrainTexture.getSplatmap();
    if (splatmap != null) {
        String splatPath = FilenameUtils.concat(projectContext.path, splatmap.getPath());
        splatmap.loadPNG(Gdx.files.absolute(splatPath));
    }

    return terrain;
}

From source file:CSVReader.java

/**
 * @param args  [0]: The name of the file.
 *//*from w ww .  jav  a  2  s  .  c  o  m*/
private static void testSingleTokens(String[] args) {
    if (debugging) {
        try {
            // read test file
            CSVReader csv = new CSVReader(new FileReader(args[0]), ',');
            try {
                while (true) {
                    System.out.println(csv.get());
                }
            } catch (EOFException e) {
            }
            csv.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    } // end if
}

From source file:com.frostwire.search.youtube.jd.Request.java

public static byte[] read(final HTTPConnectionImpl con) throws IOException {
    final InputStream is = con.getInputStream();
    byte[] ret = null;
    if (is == null) {
        // TODO: check if we have t close con here
        return null;
    }/*from  w w w .j a v  a  2  s  .  c  om*/
    ReusableByteArrayOutputStream tmpOut;
    ReusableByteArrayOutputStream tmpOut2 = ReusableByteArrayOutputStreamPool
            .getReusableByteArrayOutputStream(1048);
    final long contentLength = con.getLongContentLength();
    if (contentLength != -1) {
        final int length = contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) contentLength;
        tmpOut = ReusableByteArrayOutputStreamPool.getReusableByteArrayOutputStream(length);
    } else {
        tmpOut = ReusableByteArrayOutputStreamPool.getReusableByteArrayOutputStream(16384);
    }
    boolean okay = false;
    /* added "Corrupt GZIP trailer" for CamWinsCom */
    try {
        int len;
        while ((len = is.read(tmpOut2.getInternalBuffer())) != -1) {
            if (len > 0) {
                tmpOut.write(tmpOut2.getInternalBuffer(), 0, len);
            }
        }
        okay = true;
    } catch (final EOFException e) {
        e.printStackTrace();
        okay = true;
    } catch (final IOException e) {
        if (e.toString().contains("end of ZLIB") || e.toString().contains("Premature")
                || e.toString().contains("Corrupt GZIP trailer")) {
            //System.out.println("Try workaround for " + e);
            okay = true;
        } else {
            throw e;
        }
    } finally {
        try {
            is.close();
        } catch (final Exception e) {
        }
        try {
            /* disconnect connection */
            con.disconnect();
        } catch (final Exception e) {
        }
        ReusableByteArrayOutputStreamPool.reuseReusableByteArrayOutputStream(tmpOut2);
        if (okay) {
            ret = tmpOut.toByteArray();
        }
        ReusableByteArrayOutputStreamPool.reuseReusableByteArrayOutputStream(tmpOut);
        tmpOut = null;
        tmpOut2 = null;
    }
    return ret;
}

From source file:org.pentaho.di.www.ge.GraphEditorWebSocketTest.java

public static void copyStream(InputStream in, OutputStream out) {
    try {/*from   w w  w .  ja  va 2 s.c o  m*/
        byte[] buffer = new byte[1024];
        int len;
        while ((len = in.read(buffer)) >= 0) {
            out.write(buffer, 0, len);
        }
    } catch (EOFException e) {
        System.err.println(e);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:RMSGameScores.java

public boolean matches(byte[] candidate) throws IllegalArgumentException {
    // If no filter set, nothing can match it.
    if (this.playerNameFilter == null) {
        return false;
    }/*from w w  w.j ava2 s .c  o m*/

    ByteArrayInputStream bais = new ByteArrayInputStream(candidate);
    DataInputStream inputStream = new DataInputStream(bais);
    String name = null;

    try {
        int score = inputStream.readInt();
        name = inputStream.readUTF();
    } catch (EOFException eofe) {
        System.out.println(eofe);
        eofe.printStackTrace();
    } catch (IOException eofe) {
        System.out.println(eofe);
        eofe.printStackTrace();
    }
    return (this.playerNameFilter.equals(name));
}

From source file:RMSGameScores.java

public int compare(byte[] rec1, byte[] rec2) {

    // Construct DataInputStreams for extracting the scores from
    // the records.
    ByteArrayInputStream bais1 = new ByteArrayInputStream(rec1);
    DataInputStream inputStream1 = new DataInputStream(bais1);
    ByteArrayInputStream bais2 = new ByteArrayInputStream(rec2);
    DataInputStream inputStream2 = new DataInputStream(bais2);
    int score1 = 0;
    int score2 = 0;
    try {/*from w  w  w  . j a  v  a 2s .co m*/
        // Extract the scores.
        score1 = inputStream1.readInt();
        score2 = inputStream2.readInt();
    } catch (EOFException eofe) {
        System.out.println(eofe);
        eofe.printStackTrace();
    } catch (IOException eofe) {
        System.out.println(eofe);
        eofe.printStackTrace();
    }

    // Sort by score
    if (score1 > score2) {
        return RecordComparator.FOLLOWS;
    } else if (score1 < score2) {
        return RecordComparator.PRECEDES;
    } else {
        return RecordComparator.EQUIVALENT;
    }
}

From source file:RMSGameScores.java

/**
 * A helper method for the printScores methods.
 *///from w w  w  .  ja va 2 s.  co  m
private void printScoresHelper(RecordEnumeration re) {

    try {
        while (re.hasNextElement()) {
            int id = re.nextRecordId();
            ByteArrayInputStream bais = new ByteArrayInputStream(recordStore.getRecord(id));
            DataInputStream inputStream = new DataInputStream(bais);
            try {
                int score = inputStream.readInt();
                String playerName = inputStream.readUTF();
                System.out.println(playerName + " = " + score);
            } catch (EOFException eofe) {
                System.out.println(eofe);
                eofe.printStackTrace();
            }
        }
    } catch (RecordStoreException rse) {
        System.out.println(rse);
        rse.printStackTrace();
    } catch (IOException ioe) {
        System.out.println(ioe);
        ioe.printStackTrace();
    }
}

From source file:com.autonomousturk.crawler.fetcher.PageFetchResult.java

public void discardContentIfNotConsumed() {
    try {/*from w ww . j  a  v a 2s .c  o m*/
        if (entity != null) {
            EntityUtils.consume(entity);
        }
    } catch (EOFException e) {
        // We can ignore this exception. It can happen on compressed streams
        // which are not repeatable
    } catch (IOException e) {
        // We can ignore this exception. It can happen if the stream is
        // closed.
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:me.zhuoran.crawler4j.crawler.http.HttpFetchResult.java

/**
 * Ensures that the entity content is fully consumed and the content stream, if exists, is closed.
 * /*from   www  . j av a 2 s .c  o  m*/
 */
public void consume() {
    try {
        if (entity != null) {
            EntityUtils.consume(entity);
        }
    } catch (EOFException e) {
        // We can ignore this exception. It can happen on compressed streams
        // which are not
        // repeatable
    } catch (IOException e) {
        // We can ignore this exception. It can happen if the stream is
        // closed.
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cn.jachohx.crawler.fetcher.PageFetchResult.java

public void discardContentIfNotConsumed() {
    try {/*ww w .  jav a 2  s  . c o  m*/
        if (entity != null) {
            EntityUtils.consume(entity);
        }
    } catch (EOFException e) {
        // We can ignore this exception. It can happen on compressed streams
        // which are not
        // repeatable
    } catch (IOException e) {
        // We can ignore this exception. It can happen if the stream is
        // closed.
    } catch (Exception e) {
        e.printStackTrace();
    }
}