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

📄 getgifdata.java

📁 用jav语言开发的基于J2SE平台的中国象棋.供大家参考和学习
💻 JAVA
字号:
package chinesechess.pieces;

import java.awt.Image;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

public class GetGiFData {
	public static void main(String[] args) throws IOException, ClassNotFoundException{
		GetGiFData ggf=new GetGiFData();
		ggf.writeFile();
		ggf.readFile();
	}
	public void readFile() throws IOException, ClassNotFoundException{
		InputStream stream = new BufferedInputStream(new FileInputStream("./data/pieceObj"));
		ObjectInputStream ois=new ObjectInputStream(stream);
		PiecesObject piece=(PiecesObject)ois.readObject();
		Image i=piece.getImage(1);
		ois.close();
	} 
	public void writeFile()	throws IOException{
		InputStream streams[] ={
			new BufferedInputStream(new FileInputStream("./image/wking.gif")),
			new BufferedInputStream(new FileInputStream("./image/wadvisor.gif")),
			new BufferedInputStream(new FileInputStream("./image/wbishop.gif")),
			new BufferedInputStream(new FileInputStream("./image/wknight.gif")),
			new BufferedInputStream(new FileInputStream("./image/wrook.gif")),
			new BufferedInputStream(new FileInputStream("./image/wcannon.gif")),
			new BufferedInputStream(new FileInputStream("./image/wpawn.gif")),
				
			new BufferedInputStream(new FileInputStream("./image/bking.gif")),
			new BufferedInputStream(new FileInputStream("./image/badvisor.gif")),
			new BufferedInputStream(new FileInputStream("./image/bbishop.gif")),
			new BufferedInputStream(new FileInputStream("./image/bknight.gif")),
			new BufferedInputStream(new FileInputStream("./image/brook.gif")),
			new BufferedInputStream(new FileInputStream("./image/bcannon.gif")),
			new BufferedInputStream(new FileInputStream("./image/bpawn.gif"))};
			
		int[] types={0,1,2,3,4,5,6,7,8,9,10,11,12,13};
		int[] fileSize=new int[14];
		int totalSize=0;
		byte[][] content=new byte[14][];
		for(int i=0;i<14;i++){
			fileSize[i]=streams[i].available();
			content[i]=new byte[fileSize[i]];
			streams[i].read(content[i]);
			streams[i].close();
		}
		byte[] header={7,9,1,1,0,1,2,5,3};
		PiecesObject piece=new PiecesObject(header,types,content);
		ObjectOutputStream oos= new ObjectOutputStream(new FileOutputStream("./data/pieceObj"));
		oos.writeObject(piece);
		oos.close();
		System.out.println("totalSize:"+totalSize);
		//OutputStream os=new BufferedOutputStream(new FileOutputStream("data.pic"));
	}
	
	public static void encode(byte[] data){
	}
}

⌨️ 快捷键说明

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