⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chunk.java

📁 tiled地图编辑器是2d的,很不错的国外软件,使用起来很方便的
💻 JAVA
字号:
/* *  Mappy Plugin for Tiled, (c) 2004 * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  Adam Turk <aturk@biggeruniverse.com> *  Bjorn Lindeijer <b.lindeijer@xs4all.nl> */package tiled.plugins.mappy;import java.io.*;/** * @version $Id: Chunk.java 683 2006-06-25 14:17:37Z bjorn $ */public class Chunk{    private String headerTag;    private int chunkSize;    private ByteArrayInputStream bais;    private ByteArrayOutputStream out;    public Chunk(InputStream in) throws IOException {		byte[] header = new byte[4];		byte[] data;		int readSize;	    in.read(header);		headerTag = new String(header);		chunkSize = (int)Util.readLongReverse(in);		if (chunkSize > 0) {			ByteArrayOutputStream baos = new ByteArrayOutputStream();			data = new byte[chunkSize];			readSize = in.read(data, 0, chunkSize);			if(readSize!=chunkSize)				throw new IOException("Incomplete read!");			baos.write(data);			bais = new ByteArrayInputStream(baos.toByteArray());		}    }    public Chunk(String header) {    	headerTag = header;    	out = new ByteArrayOutputStream();    }    public boolean isGood() {    	return chunkSize > 0;    }    public boolean equals(Object o) {		if(o instanceof String) {			return o.equals(headerTag);		}else if(o instanceof Chunk) {			return ((Chunk)o).headerTag.equals(headerTag);		}		return false;    }    public int size() {    	return headerTag.length()+out.size()+4;    }    public void write(OutputStream out) throws IOException {    	byte [] data = this.out.toByteArray();    	out.write(headerTag.getBytes());    	Util.writeLongReverse((long)(data.length-(headerTag.length()+4)), out);    	out.write(data);    }    public InputStream getInputStream() {    	return bais;    }    public OutputStream getOutputStream() {    	return out;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -