打开JAR压解包里的这个 META-INF 文件夹,用记事本打开这个 MANIFEST.MF 文件,在 MIDlet-Name: 后面输入想要的名字,再保存,就OK了,有些应用软件可能不行.
专注于为中小企业提供成都网站建设、做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业保定免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
/**
* 取得当前目录下文件对象
* @return
*/
public static Iterator getFiles(File currentFile) {
Vector vector = new Vector();
File afile[] = currentFile.listFiles();
for (int i = 0; i afile.length; i++)
if (afile[i].isFile())
vector.add(afile[i]);
return vector.iterator();
}
/**
* 取得当前目录下的子目录对象列表
* @return
*/
public static Iterator getAllDirectories(File currentFile) {
Vector vector = new Vector();
File afile[] = currentFile.listFiles();
//vector.add(new File(documentRoot, relativeFile + File.separator + "."));
try {
vector.add(new File(currentFile.getCanonicalFile() + File.separator + ".."));
for (int i = 0; i afile.length; i++)
if (afile[i].isDirectory())
vector.add(afile[i]);
} catch (IOException e) {
if (log.isErrorEnabled()) log.error(e);
}
return vector.iterator();
}
/**
* 取得当前目录下的子目录对象列表
* @return
*/
public static Iterator getDirectories(File currentFile) {
Vector vector = new Vector();
File afile[] = currentFile.listFiles();
for (int i = 0; i afile.length; i++)
if (afile[i].isDirectory())
vector.add(afile[i]);
return vector.iterator();
}
/**
* 将内容写入文件
* @param file
* @param content
* @throws IOException
*/
public static void writeFile(String file, String content)
throws IOException {
PrintWriter printwriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),BIND_ENCODING)));
printwriter.write(content);
printwriter.close();
if (printwriter.checkError())
if (log.isErrorEnabled())
log.error("Error encountered while writing the file!");
else
return;
}
代码太长,分批发.
要重新设置contentType,如application/octet-stream,再加一个filename
filename="XXXXX.txt";
response.setHeader("Content-Disposition", "attachment; filename="+filename);
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class A {
public static void main(String[] args) throws Exception {
String url1 = "D:\\a.txt";// 源文件路径
String url2 = "E:\\b.txt";// 目标路径(复制到E盘,重命名为b.txt)
copy(url1, url2);
}
private static void copy(String url1, String url2) throws Exception {
FileInputStream in = new FileInputStream(new File(url1));
FileOutputStream out = new FileOutputStream(new File(url2));
byte[] buff = new byte[512];
int n = 0;
System.out.println("复制文件:" + "\n" + "源路径:" + url1 + "\n" + "目标路径:"
+ url2);
while ((n = in.read(buff)) != -1) {
out.write(buff, 0, n);
}
out.flush();
in.close();
out.close();
System.out.println("复制完成");
}
}
写一个例子
希望对你有帮助
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款