- 积分
- 213
- 实力分
- 点
- 金钱数
- 两
- 技术分
- 分
- 贡献分
- 分
|
楼主 |
发表于 2005-8-22 15:36:12
|
显示全部楼层
源码:
// Decompiled by DJ v3.4.4.74 Copyright 2003 Atanas Neshkov Date: 2005-8-22 15:21:34
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: FileCopy.java
import com.siemens.mp.io.File;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class FileCopy extends MIDlet
implements CommandListener
{
public FileCopy()
{
F = new File();
src = "a:\\";
dest = "a:\\";
FC = this;
D = Display.getDisplay(this);
}
public void startApp()
{
try
{
File.exists("a");
}
catch(Exception exception) { }
IMEI = System.getProperty("com.siemens.IMEI");
if(IMEI == null)
IMEI = "000000000000000";
MF = new Form("File copy");
MF.addCommand(new Command("Exit", 2, 1));
MF.setCommandListener(this);
D.setCurrent(MF);
try
{
int i = F.open(CURRENT);
int j = F.length(i);
if(j > 0)
{
byte abyte0[] = new byte[j];
F.read(i, abyte0, 0, j);
String s = new String(abyte0);
int l = s.indexOf('|');
if(l > 0)
{
src = s.substring(0, l);
dest = s.substring(l + 1);
}
}
F.close(i);
if(IMEI.equals("099999001234560"))
{
path = ".\\";
} else
{
for(int k = 0; k < 5; k++)
{
path = "\u012E\u012E\\" + path;
try
{
if(File.exists(path + "Address book") >= 0)
break;
}
catch(Exception exception2) { }
if(k == 5)
throw new Exception("Cannot access root filesystem");
}
}
}
catch(Exception exception1)
{
MF.append(exception1.getMessage());
return;
}
TFS = new TextField("Source:", src, 128, 0);
TFD = new TextField("Destination:", dest, 128, 0);
MF.append(TFS);
MF.append(TFD);
MF.addCommand(new Command("Copy", 4, 0));
}
public void pauseApp()
{
}
public void destroyApp(boolean flag)
{
}
public void commandAction(Command command, Displayable displayable)
{
src = TFS.getString();
dest = TFD.getString();
if(command.getCommandType() == 2)
{
try
{
File.delete(CURRENT);
int i = F.open(CURRENT);
byte abyte0[] = (src + '|' + dest).getBytes();
F.write(i, abyte0, 0, abyte0.length);
F.close(i);
}
catch(Exception exception) { }
notifyDestroyed();
} else
{
try
{
String s = fullpath(src);
String s1 = fullpath(dest);
if(File.exists(s) < 0)
throw new Exception("Source file not found");
int j = F.open(s);
if(j < 0)
throw new Exception("Filesystem error");
if(File.exists(s1) >= 0 && File.delete(s1) != 1)
throw new Exception("Cannot create destination file");
int k = F.open(s1);
if(k < 0)
throw new Exception("Filesystem error");
byte abyte1[] = new byte[8192];
int l;
while((l = F.read(j, abyte1, 0, 8192)) > 0)
F.write(k, abyte1, 0, l);
F.close(j);
F.close(k);
D.setCurrent(new Alert("File copy", "\n Success", null, null), MF);
}
catch(Exception exception1)
{
D.setCurrent(new Alert("Error", exception1.getMessage(), null, null), MF);
}
}
}
String fullpath(String s)
{
String s1 = s;
if(s.startsWith("a:\\"))
s1 = path + s.substring(3);
else
if(s.startsWith("\\"))
s1 = path + s.substring(1);
return s1;
}
static FileCopy FC;
static Display D;
static String IMEI;
static String path = "\u012E\u012E\\\u012E\u012E\\";
static String CURRENT = ".current";
File F;
Form MF;
TextField TFS;
TextField TFD;
String src;
String dest;
} |
|