首页 \ 问答 \ 求 java开发wap应用程序的教程或书

求 java开发wap应用程序的教程或书

例如开发一款wap的网络游戏。越详细越好。 求教高手!QQ413205789,验证请注明:java相关 谢谢!
更新时间:2021-05-19 12:05

最满意答案

件分割合并工具的Java源码2007/02/21 05:38 A.M.public class FileCut 
/*cl_tl*/ 
{ 
private Shell shell; 
private Display display; 
private Text txtSourceFile; 
private Text txtNewFilePath; 
private Text txtFileSize; 
private Button btnChooseFile; 
private Button btnChoosePath; 
private Button btnCut; 
private Button btnUnionFiles; 
private Button btnUp; 
private Button btnDown; 
private Button btnClear; 
private Button btnClearAll; 
private Button btnUnion; 
private Table tblFileList; 

private File sourceFile = null; /*源文件*/ 
private File[] newFile = null; /*分割后产生的文件*/ 
private int fileCount = 0; /*分割成的文件个数*/ 
private int fileSize = 0; /*分割的文件块大小*/ 
private String strSourceFile = null; /*源文件路径及名称*/ 
private String strNewFilePath = null; /*分割文件存放路径*/ 

public static void main(String[] args) 
{ 
Display display=new Display(); 
FileCut Item=new FileCut(); 
Item.createShell(); 

while( !Item.shell.isDisposed()) 
{ 
if(!display.readAndDispatch()) 
display.sleep(); 
} 
display.dispose(); 
} 

/*fn_hd 
*rem:创建窗体 
*aut: 
*log:2005-11-24 
*/ 
private void createShell() 
/*fn_tl*/ 
{ 
shell = new Shell(display, SWT.MIN); 
shell.setBounds(300,250,500,330); 
shell.setText("文件分割合并"); 
GridLayout shellLayout = new GridLayout(); 
shellLayout.numColumns = 3; 
shell.setLayout(shellLayout); 
createWidgets(); 
shell.open(); 
} 

/**fn_hd 
*rem:在窗体内添加控件 
*per: 
*aut: 
*log:2005-11-24 
*/ 
private void createWidgets() 
/*fn_tl*/ 
{ 
final Label lblNull0 = new Label(shell,SWT.None); 
GridData gd0 = new GridData(); 
gd0.horizontalSpan = 3; 
lblNull0.setLayoutData(gd0); 

final Label lblSourceFile = new Label(shell, SWT.None); 
lblSourceFile.setText("源 文 件"); 

GridData gd2 = new GridData(GridData.FILL_HORIZONTAL); 
txtSourceFile = new Text(shell, SWT.BORDER); 
txtSourceFile.setLayoutData(gd2); 

btnChooseFile = new Button(shell, SWT.PUSH); 
btnChooseFile.setText(".."); 

final Label lblPath = new Label(shell, SWT.None); 
lblPath.setText("存放路径"); 

txtNewFilePath = new Text(shell, SWT.BORDER); 
GridData gd3 = new GridData(GridData.FILL_HORIZONTAL); 
txtNewFilePath.setLayoutData(gd3); 

btnChoosePath = new Button(shell, SWT.PUSH); 
btnChoosePath.setText(".."); 

final Label lblSize = new Label(shell, SWT.None); 
lblSize.setText("分块大小(KB)"); 

txtFileSize = new Text(shell,SWT.BORDER); 
GridData gd7 = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); 
txtFileSize.setLayoutData(gd7); 

btnCut = new Button(shell, SWT.PUSH); 
GridData gd4 = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); 
btnCut.setLayoutData(gd4); 
btnCut.setText("开始分割"); 

final Label lbl1 = new Label(shell, SWT.None); 
GridData gd8 = new GridData(); 
gd8.horizontalSpan = 3; 
lbl1.setLayoutData(gd8); 
lbl1.setText("待合并的文件列表"); 

tblFileList = new Table(shell, SWT.BORDER); 
GridData gd1 = new GridData(GridData.FILL_BOTH); 
gd1.horizontalSpan = 2; 
tblFileList.setLayoutData(gd1); 

Composite com = new Composite(shell, SWT.None); 
GridLayout comLayout = new GridLayout(); 
com.setLayout(comLayout); 

final Label lblNote = new Label(shell, SWT.None); 
GridData data = new GridData(); 
data.horizontalSpan=3; 
lblNote.setLayoutData(data); 
lblNote.setText("提示:注意合并文件的顺序"); 

btnUnionFiles = new Button(com, SWT.PUSH); 
btnUnionFiles.setText("选择文件"); 

btnUp = new Button(com, SWT.PUSH); 
btnUp.setText(" 上移 "); 
btnUp.setEnabled(false); 

btnDown = new Button(com, SWT.PUSH); 
btnDown.setText(" 下移 "); 
btnDown.setEnabled(false); 

btnClear = new Button(com, SWT.PUSH); 
btnClear.setText(" 删除 "); 
btnClear.setEnabled(false); 

btnClearAll = new Button(com, SWT.PUSH); 
btnClearAll.setText("清空列表"); 

btnUnion = new Button(com, SWT.PUSH); 
btnUnion.setText("开始合并"); 

btnCut.addSelectionListener(new SelectionAdapter() 
//添加"开始分割"监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
cutButtonEvent(); 
} 
}); 

btnChooseFile.addSelectionListener(new SelectionAdapter() 
//添加选择(源文件)监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
FileDialog fdOpen = new FileDialog(shell,SWT.OPEN); 
String strFileName = fdOpen.open(); 
if (strFileName != null) 
{ 
txtSourceFile.setText(strFileName); 
txtNewFilePath.setText(fdOpen.getFilterPath()); 
txtFileSize.setFocus(); 
} 
} 
}); 

btnChoosePath.addSelectionListener(new SelectionAdapter() 
//添加选择(分割文件存放路径)监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
DirectoryDialog dirDia = new DirectoryDialog(shell); 
String strFileDir = dirDia.open(); 
if (strFileDir != null) 
{ 
txtNewFilePath.setText(strFileDir); 
txtFileSize.setFocus(); 
} 
} 
}); 

btnUp.addSelectionListener(new SelectionAdapter() 
//添加"上移"监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
//int[] itemIndices = tblFileList.getSelectionIndices(); 
int itemIndex = tblFileList.getSelectionIndex(); 
if (itemIndex == 0) 
{ 
tblFileList.setFocus(); 
return; 
} 
//交换列表中两行的内容 
String strTemp = tblFileList.getItem(itemIndex).getText(); 
tblFileList.getItem(itemIndex).setText(tblFileList.getItem( 
itemIndex - 1).getText()); 
tblFileList.getItem(itemIndex - 1).setText(strTemp); 
//设置焦点 
tblFileList.setSelection(itemIndex - 1); 
tblFileList.setFocus(); 
} 
}); 

btnDown.addSelectionListener(new SelectionAdapter() 
//添加"下移"监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
//int[] itemIndices = tblFileList.getSelectionIndices(); 
int itemIndex = tblFileList.getSelectionIndex(); 
if (itemIndex == tblFileList.getItemCount() - 1) 
{ 
tblFileList.setFocus(); 
return; 
} 
//交换列表中两行的内容 
String strTemp = tblFileList.getItem(itemIndex).getText(); 
tblFileList.getItem(itemIndex).setText(tblFileList.getItem( 
itemIndex + 1).getText()); 
tblFileList.getItem(itemIndex + 1).setText(strTemp); 
//设置焦点 
tblFileList.setSelection(itemIndex + 1); 
tblFileList.setFocus(); 
} 
}); 

btnClear.addSelectionListener(new SelectionAdapter() 
//添加"删除"监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
int itemIndex = tblFileList.getSelectionIndex(); 
tblFileList.remove(itemIndex); 
btnUp.setEnabled(false); 
btnDown.setEnabled(false); 
btnClear.setEnabled(false); 
} 
}); 

btnClearAll.addSelectionListener(new SelectionAdapter() 
//添加"清空列表"监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
tblFileList.removeAll(); 
btnUp.setEnabled(false); 
btnDown.setEnabled(false); 
btnClear.setEnabled(false); 
} 
}); 

txtFileSize.addSelectionListener(new SelectionAdapter() 
//添加"分块大小"文本框中输入回车监视器 
{ 
public void widgetDefaultSelected(SelectionEvent event) 
{ 
cutButtonEvent(); 
} 
}); 

btnUnionFiles.addSelectionListener(new SelectionAdapter() 
//添加"选择文件"监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
FileDialog fd = new FileDialog(shell, SWT.MULTI); 
fd.setFilterExtensions(new String[]{"*.dat", "*.*"}); 
if (fd.open() != null) 
{ 
String[] strFiles = fd.getFileNames(); 
String strFilePath = fd.getFilterPath(); 
//strUnionFilePath = new String[strFiles.length]; 
for(int i = 0; i < strFiles.length; i++) 
{ 
//strUnionFilePath[i] = fd.getFilterPath(); 
TableItem item = new TableItem(tblFileList, SWT.None); 
item.setText(strFilePath + "\\" + strFiles[i]); 
} 
} 
} 
}); 

btnUnion.addSelectionListener(new SelectionAdapter() 
//添加"开始合并"监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
if (tblFileList.getItemCount() == 0) 
{ 
return; 
} 
switch (unionFiles()) 
{ 
case 1: 
showMessage("成功", "合并完成!", 
SWT.OK | SWT.ICON_INFORMATION); 
tblFileList.removeAll(); 
btnUp.setEnabled(false); 
btnDown.setEnabled(false); 
btnClear.setEnabled(false); 
break; 
case -1: 
showMessage("错误", "文件不存在!", 
SWT.OK | SWT.ICON_ERROR); 
break; 
case -2: 
break; 
default: 
showMessage("错误", "有错误发生,文件合并失败!", 
SWT.OK | SWT.ICON_ERROR); 
} 
} 
}); 

tblFileList.addSelectionListener(new SelectionAdapter() 
//添加选中列表中元素监视器 
{ 
public void widgetSelected(SelectionEvent event) 
{ 
btnUp.setEnabled(true); 
btnDown.setEnabled(true); 
btnClear.setEnabled(true); 
} 
}); 
} 

/**fn_hd 
*rem:显示消息框 
*log:2005-11-24 
*/ 
private int showMessage(String strText, String strMessage, int i) 
{/*fn_tl*/ 
MessageBox msgBox = new MessageBox(shell,i); 
msgBox.setText(strText); 
msgBox.setMessage(strMessage); 
return msgBox.open(); 
} 

/**fn_hd 
*rem:点击"分割"按钮触发的事件响应 
*log:2005-11-24 
*/ 
private void cutButtonEvent() 
/*fn_tl*/ 
{ 
strSourceFile = txtSourceFile.getText().trim(); 
strNewFilePath = txtNewFilePath.getText().trim(); 

if (strSourceFile.equals("") || strNewFilePath.equals("")) 
{ 
showMessage("提示", "请输入源文件和 \n\n分割文件的路径! ", 
SWT.OK | SWT.ICON_INFORMATION); 
return; 
} 
try 
{ 
fileSize = Integer.parseInt(txtFileSize.getText()); 
fileSize *= 1024; 
if (fileSize <= 0) 
{ 
showMessage("错误", "分块大小为正整数! ", 
SWT.OK | SWT.ICON_ERROR); 
return; 
} 
} 
catch(Exception e) 
{ 
showMessage("错误", "请在分块大小框填入数字! ", 
SWT.OK | SWT.ICON_ERROR); 
return; 
} 
switch (cutFile()) 
{ 
case 1: 
showMessage("提示", "分割完成! ", SWT.OK | 
SWT.ICON_INFORMATION); 
txtSourceFile.setText(""); 
txtNewFilePath.setText(""); 
txtFileSize.setText(""); 
break; 
case -1: 
showMessage("错误", "源文件不存在或存放路径不存在!", 
SWT.OK | SWT.ICON_ERROR); 
break; 
default: 
showMessage("未知错误", "文件分割失败! ", 
SWT.OK | SWT.ICON_ERROR); 
} 
} 

/*fn_hd 
*rem:文件分割实现 
*per:成功返回1,文件未找到返回-1,其他情况返回0 
*exp:IOException 
*aut: 
*log:2005-11-22,创建 
*log:2005-11-24,修改 
*/ 
private int cutFile() 
/*fn_tl*/ 
{ 
sourceFile = new File(strSourceFile); 
fileCount = (int) (sourceFile.length() / fileSize); 
if (sourceFile.length() % fileSize != 0) 
{ 
fileCount++; 
} 
newFile = new File[fileCount]; 

try 
{ 
int count = 0; 
int i = 0; 
byte[] bueff = new byte[fileSize]; 
FileOutputStream out = null; 
FileInputStream in = new FileInputStream(sourceFile); 
for (i = 0; i < newFile.length; i++) 
{ 
newFile[i] = new File(strNewFilePath, 
i + sourceFile.getName() + ".dat"); 
} 
i = 0; 
while ((count = in.read(bueff,0,fileSize)) != -1) 
{ 
out = new FileOutputStream(newFile[i]); 
out.write(bueff,0,count); 
out.close(); 
i++; 
} 
in.close(); 
return 1; 
} 
catch(FileNotFoundException e) 
{ 
System.out.println(e); 
return -1; 
} 
catch(IOException e) 
{ 
System.out.println(e); 
return 0; 
} 
} 

/*fn_hd 
*rem:文件合并的实现 
*per:成功返回1,文件未找到返回-1,取消操作返回-2,其他情况返回0; 
*aut: 
*exp:FileNotFoundException,IOException 
*log:2005-11-28,创建 
*/ 
private int unionFiles() 
/*fn_tl*/ 
{ 
String[] strFiles = new String[tblFileList.getItemCount()]; 
File[] unionFiles = new File[strFiles.length]; 
FileDialog fdSave = new FileDialog(shell, SWT.SAVE); 
String s = fdSave.open(); 
if (s == null) 
{ 
return -2; 
} 
File outFile = new File(fdSave.getFilterPath(), 
fdSave.getFileName()); 
if (outFile.exists()) 
{ 
int msg = showMessage("提示", "该文件以存在,是否替换?", 
SWT.YES | SWT.NO | SWT.ICON_QUESTION); 
if (msg == SWT.NO) 
{ 
return -2; 
} 
} 
for(int i = 0; i < strFiles.length; i++) 
{ 
strFiles[i] = tblFileList.getItem(i).getText(); 
} 
try 
{ 
FileInputStream in = null; 
FileOutputStream out = new FileOutputStream(outFile); 
byte[] buff = new byte[1024]; 
int count; 
for(int i = 0; i < strFiles.length; i++) 
{ 
in = new FileInputStream(strFiles[i]); 
while((count = in.read(buff,0,1024)) != -1) 
{ 
out.write(buff,0,count); 
} 
in.close(); 
} 
out.close(); 
return 1; 
} 
catch(FileNotFoundException e) 
{ 
System.out.println(e); 
return -1; 
} 
catch(IOException e) 
{ 
System.out.println(e); 
return 0; 
} 
}

相关问答

更多
  • 一。 下载并安装java环境 jdk 1.4以后版本 大于1.4都可以。去sun的官网上下载 二。 下载并安装sun提供的专门开发手机软件的 java微型版,即j2me开发工具,又叫WTK全称(Wireless Toolkit)目前版本 WTK2.5.2 去sun的官网下载 如果只用写字板,记事本之类的开发工具的话,现在就可以开发了,运行WTK:->项目-新建项目,就会在C:\Documents and Settings\Administrator\j2mewtk\2.5.2\apps 下生成你的项目文件夹 ...
  • 你的手机支持JAVA吗?支持的话就能看JAR的电子书啊!TXT的你在下载后要把编码改称unicode,点保存在编码那改你试试
  • 件分割合并工具的Java源码2007/02/21 05:38 A.M.public class FileCut /*cl_tl*/ { private Shell shell; private Display display; private Text txtSourceFile; private Text txtNewFilePath; private Text txtFileSize; private Button btnChooseFile; private Button btnChoosePath; ...
  • 手机JAVA怎么用[2022-09-07]

    打开JAVA菜单就一个 设置跟 查找游戏 这很简单因为你手机上没有JAVA的游戏或软件(如一些播放器,词典什么的)只要到网上找个网下到JAVA的文件夹都是.rar格式的,再进入JAVA程序选择查找游戏找到后就会自动打开这游戏 ,下次就只要打开JAVA程序选择启动JAVA,然后就有你要的游戏了
  • 刷机步骤: 1.首先到应用商店下载一个360Root的android应用,点击打开,按照软件提示一步步操作,就可以获得Root权限。 2.下载手机对应的rom安装包。 3.将安装包导入到手机上,系统会自动安装,这就ok了。 中间如果失败的话,有可能是因为rom版本不匹配。
  • 那要看你喜欢玩什么类型的游戏
  • 1. 新买的卡,先在手机上格式你的 TF 卡:设置 ― 手机状态 ― 存储存储设备 ―卡 ― 菜单键 ― 格式,或先安装 TF 卡到手机上采取拍照,录象的方式,激活 TF 卡的文件夹。如果是已经使用的就不必了... 2.将我的电脑 ― 工具 ― 文件夹选项 ― 查看中的,隐藏文件和文件夹 ― 选显示 3.打开我的电脑 ― 工具 ― 文件夹选项 ― 查看,把 “隐藏受保护的操作系统文件”前面的勾去掉 4.然后用读卡器打开你的TF,就可以看见TF卡上的 KJAVA 了。复制游戏和软件到你TF卡的 KJAVA 目 ...
  • - - 应该是 游戏格式 你手机不支持吧

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)