JAD生成方法

JAD生成方法

 1 
 2           ///   <summary>
 3           ///  JAR文件直接生成JAD文件包
 4           ///   </summary>
 5           ///   <param name="jarfilePath"></param>
 6           private   void  BuildJad( string  jarfilePath)
 7          {
 8               string  lineStr  =   "" ;
 9               if  ( ! File.Exists(jarfilePath))  return ;
10               if  (jarfilePath.ToLower().IndexOf( " .jar " <   0 return ;
11 
12              var fileInfo  =   new  FileInfo(jarfilePath);
13              var stringBuilder  =   new  StringBuilder( " MIDlet-Jar-Size:  " );
14              stringBuilder.Append(fileInfo.Length);
15              stringBuilder.Append( " \r\n " );
16              stringBuilder.Append( " MIDlet-Jar-URL:  " );
17              stringBuilder.Append(fileInfo.Name);
18              stringBuilder.Append( " \r\n " );
19 
20               string  jadFilePath  =  jarfilePath.Remove(jarfilePath.LastIndexOf( ' . ' ))  +   " .jad " ;
21 
22               // 保存jad,dirCach为保存的jad路径
23               string  cachePath  =   @" E:\temp "   +  DateTime.Now.ToString( " yyyy " +   @" \ "   +  DateTime.Now.ToString( " MM " +   @" \ "   +
24                               DateTime.Now.ToString( " dd " );
25         
26               if  ( ! Directory.Exists(cachePath))
27                  Directory.CreateDirectory(cachePath);
28 
29              DecompressRar(jarfilePath,  cachePath);
30              var sr  =   new  StreamReader(cachePath  +   " \\META-INF\\MANIFEST.MF " );
31               while  ((lineStr  =  sr.ReadLine())  !=   null )
32              {
33                  stringBuilder.Append(lineStr).Append( " \r\n " );
34              }
35              sr.Close();
36 
37               // 删除解开的数据
38              Directory.Delete(cachePath,  true );
39               if  (File.Exists(jadFilePath))
40              {
41                   // 备份数据
42                   string  pathBak  =  fileInfo.DirectoryName.ToLower().Replace( " uploads " " uploadsBakJad " );
43                   if  ( ! Directory.Exists(pathBak))
44                      Directory.CreateDirectory(pathBak);
45                  File.Delete(jadFilePath.ToLower().Replace( " uploads " " uploadsBakJad " ));
46                  File.Move(jadFilePath, jadFilePath.ToLower().Replace( " uploads " " uploadsBakJad " ));
47              }
48              StreamWriter wr  =  File.CreateText(jadFilePath);
49              wr.Write(stringBuilder);
50              wr.Close();
51              log.Info( " file  "   +  jarfilePath  +   "  is ok  " );
52          }
53 
54           private   static   void  DecompressRar( string  rarFileToDecompress,  string  directoryToSave)
55          {
56               string  winrarExe  =  ConfigurationManager.AppSettings[ " winrarExepath " ];
57               if  ( new  FileInfo(winrarExe).Exists)
58              {
59                   try
60                  {
61                      Process p  =   new  Process();
62                       //  需要启动的程序名
63                      p.StartInfo.FileName  =  winrarExe;
64                       //  参数
65                       string  arguments  =   @" x -inul -y -o+ " ;
66                      arguments  +=   "   "   +  rarFileToDecompress  +   "   "   +  directoryToSave;
67                      p.StartInfo.Arguments  =  arguments;
68                      p.Start(); // 启动
69                       while  ( ! p.HasExited)
70                      { }
71                      p.WaitForExit();
72                  }
73                   catch  (Exception ee)
74                  {
75                       throw   new  Exception(ee.Message);
76                  }
77              }
78          }


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
黑莓JAD打包是指将应用程序打包成JAD格式,以供黑莓手机用户进行下载安装。以下是黑莓JAD打包下载的步骤: 1. 准备原始应用程序:首先需要有一个已经开发完善的黑莓应用程序,并确保它能在黑莓设备上运行。 2. 创建JAD文件:打开Java Development Environment (JDE) 或 BlackBerry Java Plug-in for Eclipse,并在此工具中创建一个新的BlackBerry项目。在项目中,选择“创建JAD文件”选项并填写应用程序的相关信息,例如应用程序名称、版本号、作者等。 3. 填写应用程序信息:在JAD文件中,您还可以填写其他应用程序信息,比如图标、描述、权限等。确保填写的信息准确和完整。 4. 打包应用程序:根据您的JAD文件,使用JDE或BlackBerry Java Plug-in for Eclipse将应用程序打包成COD文件格式。COD文件包含了应用程序的实际代码和资源。 5. 生成JAD和COD文件:在打包过程完成后,您将会得到一个COD文件和相应的JAD文件。这两个文件应该位于同一目录中。 6. 上传到服务器:将JAD和COD文件上传至可信任的服务器,以供用户下载。确保服务器可以支持JAD和COD文件的托管。 7. 提供下载链接:将JAD文件的下载链接提供给用户,他们可以通过点击链接来下载和安装您打包的应用程序。 总结起来,黑莓JAD打包下载是将已开发的黑莓应用程序打包为JAD格式,然后将打包后的JAD文件上传至服务器提供下载。用户可以通过下载链接获取JAD文件,并根据JAD文件进行应用程序的安装。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值