1. 怎么用java获取应用程序里面的数据?
未读邮件的个数一般存于数据库中,你只需要连接好数据库,然后利用实体类将值引出,存入一个对象中,如果要显示该值,只需要在需要显示的地方输出就可以了,不需要用到什么多难的技术,一般的MVC或者简单的JSP语言都可以实现。
如果还有问题,可以继续追问
2. 用java获取系统已安装的软件
也只能调用本地代码了,查阅下native方法,Linux下有无注册表这样的东西我不清楚,如果没有的话Java岂不是要提供Win专有的包了?
还有native也不仅仅调用c/c++而已,听一些牛人说用Delphi或汇编也可以实现native,C++/Delphi获取注册表信息的操作应该是易如反掌的,Linux下编程就不清楚了
3. 帮忙用java写一个程序,读取txt后把里面的数据进行排列后再写出
你都没说txt里面的数据是什么格式,怎么写啊?
思路很简单,读取到Map中,学号为key,学号+姓名+性别为val。
然后key排序即可。
请考虑txt很大时对内存和效率的要求。
4. java,编写一个程序,可以读取文件数据
package dome.myword.test;import java.io.BufferedInputStream;import java.io.BufferedReader;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.IOException;public class Myword { public static void main(String[] args) throws IOException { try { FileInputStream file = new FileInputStream("e:/myText.txt"); BufferedInputStream Bfile = new BufferedInputStream(file); byte[] b = new byte[1024]; String s = ""; int bytesRead=0; while((bytesRead=Bfile.read(b))!=-1){ s+= new String(b,0,bytesRead); } System.out.println(s); String[] words = s.split(" "); int sum = words.length; int max = words[0].length(); String maxWord = ""; int avgs = 0; for (int i = 1; i max) { max = Math.max(max, words[i].length()); maxWord = words[i]; } avgs = avgs+words[i].length()+words[0].length(); } String path = "e:/myText.txt" ; FileReader fr = new FileReader(path); BufferedReader br = new BufferedReader(fr); int x = 0; while(br.readLine() != null) { x++; } System.out.println("总行数"+x); int avg = avgs/sum; System.out.println("平均长度:"+avg); System.out.println("最长单词:"+maxWord); System.out.println("单词总数:"+sum); Bfile.close(); String fileName = "e:/mytextdata.txt"; FileOutputStream out = new FileOutputStream(fileName); String str ="单词总数:"+sum+"\r\n"+ "总行数:"+x+"\r\n"+"最长单词:"+maxWord+"\r\n"+"平均长度:"+avg; out.write(str.getBytes()); out.close(); System.out.println("输出文本完毕"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}有问题再叫我。下面是测试结果
5. 编写一个java程序, 可以读取java文件,并读取出所有内容,并自动对{和}涉及到的空格进行自动修改。
import java.io.File;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.println("行数: " + getLineCountOfFile("c:\\1.txt"));
}
public static int getLineCountOfFile(String filePath) {
int lineCount = 0;
Scanner scanner = null;
try {
scanner = new Scanner(new File(filePath));
while (scanner.hasNextLine()) {
System.out.println("文件内容: " + scanner.nextLine());
++lineCount;
}
} catch (Exception e) {
} finally {
if (scanner != null) {
scanner.close();
}
}
return lineCount;
}
}
6. 用java语言编写程序,把一个已存在的txt文件读出来并写进另一个txt文件中.
import java.io.BufferedReader;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;public class CopyDemo { public static void main(String[] args) throws Exception { //选择你要读取的文件 FileInputStream fis=new FileInputStream("E:\\圣彼得的送葬队伍 下.txt"); //选择你要存放的文件 FileOutputStream fos=new FileOutputStream("E:\\copy.txt"); //byte[] buf=new byte[1024];// BufferedReader bufr=new BufferedReader(buf); int len; while((len=fis.read())!=-1){ fos.write(len); } fis.close(); fos.close(); }}
7. 从其他软件传数据到本软件,用java怎么得到这个数据呢
WebService?这个现在比较流行。
8. java后台怎么获取app传过来的数据
java后台写好接口,在APP端将要传递的数据封装好,然后调用后台的接口就是了