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

📄 mkjad.java

📁 J2ME的游戏原代码!希望能帮助有需要帮助的师兄弟们!
💻 JAVA
字号:
import java.io.*;
import java.util.*;

/**
 * This program uses the manifest file and the size of a
 * JAR-file to create a JAD-file.
 * 
 * @author Joakim Roubert 2003
 */
public class mkjad
{
	public static void main (String[] args)
	{
		String JARFile, MANIFESTFile, JADFile;
		JARFile = null;
		MANIFESTFile = null;
		JADFile = null;

		String usage = "mkjad 1.00 by Joakim Roubert 2003\n\nCreates a JAD file.\n\nUsage: java mkjlang [JAR-file] [MANIFEST-file] [output JAD-file]";

		if (args.length != 3)
		{
			System.err.println(usage);
			System.exit(1);
		}

		try
		{
			JARFile = args[0];
			MANIFESTFile = args[1];
			JADFile = args[2];
		}
		catch (ArrayIndexOutOfBoundsException e)
		{
			System.err.println("usage");
            System.exit(1);
		}

		processJAD p = new processJAD(JARFile, MANIFESTFile, JADFile);
		if (p.process())
			System.exit(0);
		else
			System.exit(1);
	}
}

/**
 * The JAD processing.
 */
class processJAD
{
	InputStreamReader in;
	OutputStreamWriter out;
	String JADFile, MANIFESTFile, JARFile;
	int size;

	public processJAD(String JARFile, String MANIFESTFile, String JADFile)
	{
		try
		{
			size = (new FileInputStream(JARFile)).available();
		}
		catch (IOException ie)
		{
			System.err.println("Error: File " + JARFile + " is not valid.");
			System.exit(1);
		}
		try
        {
			in = new InputStreamReader(new FileInputStream(MANIFESTFile));
		}
		catch (IOException ie)
		{
			System.err.println("Error: File " + MANIFESTFile + " is not valid.");
			System.exit(1);
		}
		try
		{
			out = new OutputStreamWriter(new FileOutputStream(JADFile), "ISO-8859-1");
		}
		catch(IOException ie)
		{
			System.err.println("Error: Could not write to file " + JADFile + ".");
			System.exit(1);
		}

		this.JARFile = JARFile;
		this.MANIFESTFile = MANIFESTFile;
		this.JADFile = JADFile;
	}

	/**
	 * Reads a line from infile and strips ending ^M stuff.
	 */
	private String readLine() throws IOException
	{
		StringBuffer buffy = new StringBuffer();
		int c = 0;
		while (c != '\n')
		{
			try
			{
				c = in.read();
				if (c != -1)
				{
					buffy.append((char) c);
				}
				else
					return null;
			}
			catch (IOException ie)
			{
				throw ie;
			}
		}
		buffy.setLength(buffy.length()-1);
		return buffy.toString();
	}

	/**
	 * Process the file.
	 */
	public boolean process()
	{
		try
		{
			int i;
			String tmp = readLine();
			for (i=1; tmp != null; i++)
			{
				if (!(tmp.startsWith("MicroEdition-")))
					out.write(tmp + "\n");
				tmp = readLine();
			}
			out.write("MIDlet-Jar-Size: " + size + "\n");
			int idx = JARFile.lastIndexOf('\\');
			out.write("MIDlet-Jar-URL: " + JARFile.substring(idx+1, JARFile.length()) + "\n");
			out.write("X-SonyEricsson-HighscoreDNS: http://cip-ext.aus.teleca.se/cip/highscore/index.jsp\n");
			out.close();
			in.close();
		}
		catch (IOException ie)
		{
			System.out.println("Error: I/O error creating JAD-file");
			return false;
		}
		return true;
	}
}

⌨️ 快捷键说明

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