當前位置:首頁 » 編程語言 » java管理系統

java管理系統

發布時間: 2022-01-10 18:04:40

Ⅰ 用java編寫學生管理系統

我也是初學寫的不好
public class Student {
static int[] gradesArray={87,68,94,100,83,78,85,91,76,87};
public Student(int[]gradesArray){

}
public void printAllGrade(){
for (int i = 0; i < gradesArray.length; i++) {
System.out.println("學號"+(i+1)+"成績是"+gradesArray[i]);
}
}
public void printAvarage(){
double sum = 0;
for (int i = 0; i < gradesArray.length; i++) {
sum+=gradesArray[i];
}
System.out.println("\n平均成績是"+sum/gradesArray.length);
}
public void printMax(){
int max=gradesArray[0];
for (int i = 0; i < gradesArray.length; i++) {
if(gradesArray[i]>max){
max=gradesArray[i];
}
}
System.out.println("\n最高分時"+max);
}
public void printMin(){
int min=gradesArray[0];
for (int i = 0; i < gradesArray.length; i++) {
if (gradesArray[i]<min){
min=gradesArray[i];
}
}
System.out.println("\n最低分時"+min);
}
public void printDistribution(){
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;
for (int i = 0; i < gradesArray.length; i++) {
if(gradesArray[i]<10){
a++;
}else if (gradesArray[i]>=10&&gradesArray[i]<20) {
b++;
}
else if (gradesArray[i]>=20&&gradesArray[i]<30) {
c++;
}
else if (gradesArray[i]>=30&&gradesArray[i]<40) {
d++;
}
else if (gradesArray[i]>=40&&gradesArray[i]<50) {
e++;
}
else if (gradesArray[i]>=50&&gradesArray[i]<60) {
f++;
}
else if (gradesArray[i]>=60&&gradesArray[i]<70) {
g++;
}
else if (gradesArray[i]>=70&&gradesArray[i]<80) {
h++;
}
else if (gradesArray[i]>=80&&gradesArray[i]<90) {
j++;
}
else if (gradesArray[i]>=90&&gradesArray[i]<100) {
k++;
}
}
System.out.println("\n成績分布是");
System.out.print("0-10:");
for (int i = 0; i <=a; i++) {
System.out.print("*");
}
System.out.print("10-20:");
for (int i = 0; i <=b; i++) {
System.out.print("*");
}
System.out.print("20-30:");
for (int i = 0; i <=c; i++) {
System.out.print("*");
}
System.out.print("30-40:");
for (int i = 0; i <=d; i++) {
System.out.print("*");
}
System.out.print("40-50:");
for (int i = 0; i <=e; i++) {
System.out.print("*");
}
System.out.print("50-60:");
for (int i = 0; i <=f; i++) {
System.out.print("*");
}
System.out.print("60-70:");
for (int i = 0; i <=g; i++) {
System.out.print("*");
}
System.out.print("70-80:");
for (int i = 0; i <=h; i++) {
System.out.print("*");
}
System.out.print("80-90:");
for (int i = 0; i <=j;i++) {
System.out.print("*");
}
System.out.print("90-100:");
for (int i = 0; i <=k; i++) {
System.out.print("*");
}
}
public static void main(String[] args) {
Student student=new Student(gradesArray);
student.printAllGrade();
student.printAvarage();
student.printMax();
student.printMin();
student.printDistribution();
}

}

Ⅱ Java程序:手機管理系統

手機一般不說單純用java系統的,但是早期的半智能機必然基於java的平台,很多山寨機都這樣,可以直接運行java程序,因為裡面內置了JVM(java虛擬機)。由於java跨平台的特性,所以能夠運行。其實現在的安卓也是如此,安卓是JAVAME的一個分支,起根源還是java平台。其實安卓的概念早在上個世紀已經被提出,然後當時硬體條件跟不上,所以才沒有流行。總結:早期的半智能機和現在的安卓手機,都可以說是基於java平台的,但都不能明確說是java的系統。

Ⅲ java信息管理系統

採用面對對象的設計思想,一個類的各種屬性都要在裡面。。肯定一個用戶類包含所有的用戶信息,不光是這個,還要包含用戶的狀態信息。分類類別。等等信息。。
不用網路和資料庫的話肯定要用流的思想,就是為每一個用戶建立一個文件,然後採用查詢的方式,調用文件信息。讀出信息。。
查詢的話可以採用一些關鍵字索引。。可以採用希爾排序的類似方法來採取高效查找關鍵字,(折半查找也可行)

Ⅳ 如何做一個java管理系統

首先你打算用什麼技術來實現這個系統,先想好用哪些東西,是純粹的jsp,servlet+javabean還是用到struts,spring等框架,將用到的技術想到後,再進行下一步.
其次你要搭建基於你使用的開發技術的環境,如果用jsp,servlet,javabean的話只需要個tomcat類似的容器就行了,如果要用到struts或者spring等相關的框架的話,就去下載相關的文件,如果用EJB的話,去裝個jboss或者weblogic等EJB容器.
再次,環境搭建好之後就進入真正的開發了,進行需求分析,uml建模,設計好層次結構,然後進行編碼,編碼好後進行測試,不斷改進,最後交付使用了.
呵呵,如果你不懂的話現看看相關的資料再進行開發,不要茫無目的的動手編碼。

Ⅳ java控制台學生信息管理系統

你好,你要的學生信息管理系統。


(1) Student類

importjava.io.Serializable;

/**
*@authorliuxe
*@sinceJDK1.7.0_79
*/
{
privateintstuId;
privateStringname;
privateStringmajor;
privateStringsex;
privateStringcontactWay;

publicintgetStuId(){
returnstuId;
}

publicvoidsetStuId(intstuId){
this.stuId=stuId;
}

publicStringgetName(){
returnname;
}

publicvoidsetName(Stringname){
this.name=name;
}

publicStringgetMajor(){
returnmajor;
}

publicvoidsetMajor(Stringmajor){
this.major=major;
}

publicStringgetSex(){
returnsex;
}

publicvoidsetSex(Stringsex){
this.sex=sex;
}

publicStringgetContactWay(){
returncontactWay;
}

publicvoidsetContactWay(StringcontactWay){
this.contactWay=contactWay;
}
}

(2) StuMis類

importjava.io.*;
importjava.util.ArrayList;
importjava.util.List;

/**
*@authorliuxe
*@sinceJDK1.7.0_79
*/
publicclassStuMis{
publicstaticList<Student>studentList=newArrayList<Student>();

publicstaticbooleanadd(Studentstudent){
returnstudentList.add(student);
}

publicstaticbooleanremove(Studentstudent){
returnstudentList.remove(student);
}

publicstaticbooleanupdate(Studentstudent){
for(Studentdto:studentList){
if(student.getStuId()==dto.getStuId()){
studentList.remove(dto);
}
}
returnstudentList.add(student);
}

(intid){
for(Studentdto:studentList){
if(id==dto.getStuId()){
returndto;
}
}
returnnull;
}

publicstaticList<Student>queryByName(Stringname){
List<Student>returnList=newArrayList<Student>();
for(Studentdto:studentList){
if(name.equals(dto.getName())){
returnList.add(dto);
}
}
returnreturnList;
}

publicstaticvoidsaveToFile(){
try{
ObjectOutputStreamoo=newObjectOutputStream(newFileOutputStream(
newFile("."+File.separator+"student.dat")));
oo.writeObject(studentList);
}catch(Exceptionex){
ex.printStackTrace();
}
}

publicstaticvoidreadFromFile(){
try{
ObjectInputStreamois=newObjectInputStream(newFileInputStream(
newFile("."+File.separator+"student.dat")));
studentList=(List<Student>)ois.readObject();
}catch(Exceptionex){
ex.printStackTrace();
}
}
}

(3)、StuMisTest類:主函數測試學生信息管理系統

importjava.util.List;

/**
*@authorliuxe
*@sinceJDK1.7.0_79
*/
publicclassStuMisTest{
publicstaticvoidmain(String[]args){
Studentstudent=newStudent();
student.setStuId(1);
student.setName("AAA");
student.setMajor("AAAA");
student.setSex("A");
student.setContactWay("AA");
Studentstudent2=newStudent();
student2.setStuId(2);
student2.setName("BBB");
student2.setMajor("BBBB");
student2.setSex("B");
student2.setContactWay("BB");
Studentstudent3=newStudent();
student3.setStuId(3);
student3.setName("CCC");
student3.setMajor("CCCC");
student3.setSex("C");
student3.setContactWay("CC");

//A、增加一個學生記錄
StuMis.add(student);
StuMis.add(student2);
StuMis.add(student3);

//B、刪除一個學生記錄
StuMis.remove(student2);

//C、修改學生信息
student.setMajor("DDDD");
StuMis.update(student);

//D、根據學號查找學生
StudentstudentXX=StuMis.queryByStuId(3);

//E、根據姓名查找學生。。。
List<Student>studentOO=StuMis.queryByName("AAA");

//F、將集合中所有學生信息存儲到student.dat中。
StuMis.saveToFile();

//G、再次運行系統時載入student.dat中的學生信息,後支持A~E基本操作。
StuMis.readFromFile();
}
}

Ⅵ 用java設計一個資料庫管理系統

import java.sql.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
//import java.awt.event.*;
public class DisplayDemo extends JFrame
//implements ActionListener
{
// private String dbURL="jdbc:microsoft:sqlserver://202.115.26.181:1433"; // 資料庫標識名
private String user="devon"; // 資料庫用戶
private String password="book"; // 資料庫用戶密碼
private JTable table;
private JButton ok,canel;
public DisplayDemo(){
super("顯示資料庫查詢結果"); //調用父類構造函數
String[] columnNames={"用戶名","年齡","性別","Email"}; //列名
Object[][] rowData=new Object[5][4]; //表格數據
ok=new JButton("確定");
canel=new JButton("取消");
// ok.addActionListener(this);
// canel.addActionListener(this);
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:example","sa","");
// Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); //載入驅動器
// Connection con=DriverManager.getConnection(dbURL,user,password); //獲取連接
String sqlStr="select * from users"; //查詢語句
PreparedStatement ps=con.prepareStatement(sqlStr); //獲取PreparedStatement對象
ResultSet rs=ps.executeQuery(); //執行查詢
String name,sex,email; //查詢結果
int age;
int count=0;
while (rs.next()){ //遍歷查詢結果
rowData[count][0]=rs.getString("name"); //初始化數組內容
rowData[count][1]=Integer.toString(rs.getInt("age"));
rowData[count][2]=rs.getString("sex");
rowData[count][3]=rs.getString("email");
count++;
}

con.close(); //關閉連接
}
catch(Exception ex){
ex.printStackTrace(); //輸出出錯信息
}

Container container=getContentPane(); //獲取窗口容器
//container.setLayout(null);
container.add(ok);container.add(canel); ok.setBounds(10,120,70,20);
canel.setBounds(100,120,70,20);
table=new JTable(rowData,columnNames); //實例化表格
table.getColumn("年齡").setMaxWidth(25); //設置行寬
container.add(new JScrollPane(table),BorderLayout.CENTER); //增加組件

setSize(300,200); //設置窗口尺寸
setVisible(true); //設置窗口可視
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //關閉窗口時退出程序
}

public static void main(String[] args){
new DisplayDemo();
}
}

-----------------
這是其中一個例子 你照著上面做就可以了

Ⅶ java學生管理系統

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;

public class Students extends Applet implements ActionListener
{
Vector StuInf=new Vector();
StudentInf SI;
String xm;
String bj;
int i,j,xh,cj;
static int mid;
Label prompt1=new Label("學生成績管理系統");
Label prompt2=new Label(" 用戶:");
Label prompt3=new Label(" 密碼:");
Label prompt4=new Label(" 班級:");
Label prompt5=new Label(" 成績:");
TextField input1=new TextField(8);
TextField input2=new TextField(8);
TextField input3=new TextField(8);
TextField input4=new TextField(8);
Button btn1=new Button("登錄");
Button btn2=new Button("增加");
Button btn3=new Button("修改");
Button btn4=new Button("刪除");

public void init()
{
setLayout(new GridLayout(6,3));
add(new Label());
add(prompt1);
add(new Label());
add(prompt2);
add(input1);
add(new Label());
add(prompt3);
add(input2);
add(btn1);
add(prompt4);
add(input3);
add(new Label());
add(prompt5);
add(input4);
add(new Label());
add(btn2);
add(btn3);
add(btn4);
prompt4.setVisible(false);
prompt5.setVisible(false);
input3.setVisible(false);
input4.setVisible(false);
btn2.setVisible(false);
btn3.setVisible(false);
btn4.setVisible(false);
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()=="登錄")
{
String a,b;
a=input1.getText();
b=input2.getText();
input1.setText("");
if((a.equals("12")==true)&&(b.equals("12")==true))
{
prompt2.setText(" 姓名:");
prompt3.setText(" 學號:");
prompt4.setVisible(true);
prompt5.setVisible(true);
input3.setVisible(true);
input4.setVisible(true);
btn2.setVisible(true);
btn3.setVisible(true);
btn4.setVisible(true);
btn3.setEnabled(false);
btn4.setEnabled(false);
btn1.setLabel("查詢");
input1.setText("登錄成功");
input1.selectAll();
}
else
input2.setText("用戶名或密碼錯");
}
if(e.getActionCommand()=="增加")
{
boolean scucss=true;
try
{
XingMing();
}
catch(EmptyException as)
{
input1.setText("姓名不能為空");
scucss=false;
}
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("學號為空或格式錯");
scucss=false;
}
bj=input3.getText();
try
{
ChengJi();
}
catch(EmptyException as)
{
cj=-1;
}
catch(OverException dd)
{
input4.setText("應在0-100間");
scucss=false;
}
catch(NumberFormatException cm)
{
input4.setText("成績應為數據");
scucss=false;
}
if(scucss==true)
{
SI=new StudentInf(xm,xh,bj,cj);
Insert(SI);
}
}
if(e.getActionCommand()=="修改")
{
xm=input1.getText();
xh=Integer.parseInt(input2.getText());
bj=input3.getText();
cj=Integer.parseInt(input4.getText());
SI=new StudentInf(xm,xh,bj,cj);
StuInf.setElementAt(SI, mid);
btn3.setEnabled(false);
}
if(e.getActionCommand()=="刪除")
{
StuInf.removeElementAt(mid);
btn4.setEnabled(false);
input1.setText("刪除成功");
input2.setText("");
input3.setText("");
input4.setText("");
}
if(e.getActionCommand()=="查詢")
{
boolean right=true;
try
{
xh=Integer.parseInt(input2.getText());
}
catch(NumberFormatException m)
{
input2.setText("學號為空或格式錯");
right=false;
}
if(right==true)
{
search(xh);
btn3.setEnabled(true);
btn4.setEnabled(true);
}
}

}
//查找方法
public void search(int k)
{
boolean exist=false;
int low=0;
int high=StuInf.size()-1;
while(low<=high)
{
mid=(high+low)/2;
StudentInf a1=(StudentInf) StuInf.elementAt(mid);
if(a1.getStuNo()==k)
{
SI=(StudentInf) StuInf.elementAt(mid);
String x = String.valueOf(SI.getStuNo());
exist=true;
input1.setText(SI.getname());
input1.selectAll();
input2.setText("0"+x);
input3.setText(SI.getClassNo());
if(SI.getLevel()==-1)
input4.setText("未參加考試");
else
{
String y = String.valueOf(SI.getLevel());
input4.setText(y);
}
break;
}
else if(a1.getStuNo()<k)
low=mid+1;
else
high=mid-1;
}
if(exist==false)
{
input1.setText("無此學號學生信息");
input1.selectAll();
}
}
//添加方法
public void Insert(StudentInf q)
{
int i=0;

if(StuInf.isEmpty()==true)
{
StuInf.addElement(q);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
else
{
StudentInf xh;
xh=(StudentInf) StuInf.firstElement();
while(xh.getStuNo()<q.getStuNo())
{
i++;
if(i<StuInf.size())
xh=(StudentInf) StuInf.elementAt(i);
else
break;
}
if(xh.getStuNo()==q.getStuNo())
{
input2.setText("此學生信息已存在");
input2.requestFocus();
input2.selectAll();
}
else
{
StuInf.insertElementAt(q,i);
input1.setText("");
input2.setText("");
input3.setText("");
input4.setText("");
}
}
}

//異常類
class OverException extends Exception
{
String over;
}
class EmptyException extends Exception
{
String empty;
}
void XingMing() throws EmptyException
{
if((input1.getText()).equals(""))
throw (new EmptyException());
else
xm=input1.getText();
}
void ChengJi() throws OverException,EmptyException
{
if((input4.getText()).equals(""))
throw(new EmptyException());
else
cj=Integer.parseInt(input4.getText());
if(cj<0||cj>100)
throw (new OverException());
}

//學生信息類
public class StudentInf
{
private String name;
private int StuNo;
private String ClassNo;
private int Level;
StudentInf(String xingming,int xuehao,String banji,int chengji)
{
name=xingming;
StuNo=xuehao;
ClassNo=banji;
Level=chengji;
}
public int getStuNo()
{
return StuNo;
}
public String getname()
{
return name;
}
public String getClassNo()
{
return ClassNo;
}
public int getLevel()
{
return Level;
}
}

}

Ⅷ 用java來實現一個進程管理系統

構造方法摘要
ProcessBuilder(List<String> command)
利用指定的操作系統程序和參數構造一個進程生成器。
ProcessBuilder(String... command)
利用指定的操作系統程序和參數構造一個進程生成器。

方法摘要
List<String> command()
返回此進程生成器的操作系統程序和參數。
ProcessBuilder command(List<String> command)
設置此進程生成器的操作系統程序和參數。
ProcessBuilder command(String... command)
設置此進程生成器的操作系統程序和參數。
File directory()
返回此進程生成器的工作目錄。
ProcessBuilder directory(File directory)
設置此進程生成器的工作目錄。
Map<String,String> environment()
返回此進程生成器環境的字元串映射視圖。
boolean redirectErrorStream()
通知進程生成器是否合並標准錯誤和標准輸出。
ProcessBuilder redirectErrorStream(boolean redirectErrorStream)
設置此進程生成器的 redirectErrorStream 屬性。
Process start()
使用此進程生成器的屬性啟動一個新進程。

2.1.2 Runtime
每個 Java 應用程序都有一個 Runtime 類實例,使應用程序能夠與其運行的環境相連接。可以通過 getRuntime 方法獲取當前運行時。
應用程序不能創建自己的 Runtime 類實例。但可以通過 getRuntime 方法獲取當前Runtime運行時對象的引用。一旦得到了一個當前的Runtime對象的引用,就可以調用Runtime對象的方法去控制Java虛擬機的狀態和行為。

Java代碼
void addShutdownHook(Thread hook)
注冊新的虛擬機來關閉掛鉤。
int availableProcessors()
向 Java 虛擬機返回可用處理器的數目。
Process exec(String command)
在單獨的進程中執行指定的字元串命令。
Process exec(String[] cmdarray)
在單獨的進程中執行指定命令和變數。
Process exec(String[] cmdarray, String[] envp)
在指定環境的獨立進程中執行指定命令和變數。
Process exec(String[] cmdarray, String[] envp, File dir)
在指定環境和工作目錄的獨立進程中執行指定的命令和變數。
Process exec(String command, String[] envp)
在指定環境的單獨進程中執行指定的字元串命令。
Process exec(String command, String[] envp, File dir)
在有指定環境和工作目錄的獨立進程中執行指定的字元串命令。
void exit(int status)
通過啟動虛擬機的關閉序列,終止當前正在運行的 Java 虛擬機。
long freeMemory()
返回 Java 虛擬機中的空閑內存量。
void gc()
運行垃圾回收器。
InputStream getLocalizedInputStream(InputStream in)
已過時。 從 JDK 1.1 開始,將本地編碼位元組流轉換為 Unicode 字元流的首選方法是使用 InputStreamReader 和 BufferedReader 類。
OutputStream getLocalizedOutputStream(OutputStream out)
已過時。 從 JDK 1.1 開始,將 Unicode 字元流轉換為本地編碼位元組流的首選方法是使用 OutputStreamWriter、BufferedWriter 和 PrintWriter 類。
static Runtime getRuntime()
返回與當前 Java 應用程序相關的運行時對象。
void halt(int status)
強行終止目前正在運行的 Java 虛擬機。
void load(String filename)
載入作為動態庫的指定文件名。
void loadLibrary(String libname)
載入具有指定庫名的動態庫。
long maxMemory()
返回 Java 虛擬機試圖使用的最大內存量。
boolean removeShutdownHook(Thread hook)
取消注冊某個先前已注冊的虛擬機關閉掛鉤。
void runFinalization()
運行掛起 finalization 的所有對象的終止方法。
static void runFinalizersOnExit(boolean value)
已過時。 此方法本身具有不安全性。它可能對正在使用的對象調用終結方法,而其他線程正在操作這些對象,從而導致不正確的行為或死鎖。
long totalMemory()
返回 Java 虛擬機中的內存總量。
void traceInstructions(boolean on)
啟用/禁用指令跟蹤。
void traceMethodCalls(boolean on)
啟用/禁用方法調用跟蹤。

2.1.3 Process
不管通過那種方法啟動進程後,都會返回一個Process類的實例代表啟動的進程,該實例可用來控制進程並獲得相關信息。Process 類提供了執行從進程輸入、執行輸出到進程、等待進程完成、檢查進程的退出狀態以及銷毀(殺掉)進程的方法:

Java代碼
void destroy()
殺掉子進程。
一般情況下,該方法並不能殺掉已經啟動的進程,不用為好。
int exitValue()
返回子進程的出口值。
只有啟動的進程執行完成、或者由於異常退出後,exitValue()方法才會有正常的返回值,否則拋出異常。
InputStream getErrorStream()
獲取子進程的錯誤流。
如果錯誤輸出被重定向,則不能從該流中讀取錯誤輸出。
InputStream getInputStream()
獲取子進程的輸入流。
可以從該流中讀取進程的標准輸出。
OutputStream getOutputStream()
獲取子進程的輸出流。
寫入到該流中的數據作為進程的標准輸入。
int waitFor()
導致當前線程等待,如有必要,一直要等到由該 Process 對象表示的進程已經終止。

通過該類提供的方法,可以實現與啟動的進程之間通信,達到交互的目的。

2.2 實例

2.2.1 創建子進程
要創建子進程可以通過使用使用ProcessBuilder的start()方法和Runtime的exec()方法。
(1)Runtime.exec()

Java代碼
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;

public class Test1 {
public static void main(String[] args) {
try {
Process p = null;
String line = null;
BufferedReader stdout = null;

//list the files and directorys under C:\
p = Runtime.getRuntime().exec("CMD.exe /C dir", null, new File("C:\\"));
stdout = new BufferedReader(new InputStreamReader(p
.getInputStream()));
while ((line = stdout.readLine()) != null) {
System.out.println(line);
}
stdout.close();

//echo the value of NAME
p = Runtime.getRuntime().exec("CMD.exe /C echo %NAME%", new String[] {"NAME=TEST"});
stdout = new BufferedReader(new InputStreamReader(p
.getInputStream()));
while ((line = stdout.readLine()) != null) {
System.out.println(line);
}
stdout.close();
} catch (Exception e) {
e.printStackTrace();
}
}

(2)ProcessBuilder

Java代碼
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Test2 {
public static void main(String[] args) {
try {
List<String> list = new ArrayList<String>();
ProcessBuilder pb = null;
Process p = null;
String line = null;
BufferedReader stdout = null;

//list the files and directorys under C:\
list.add("CMD.EXE");
list.add("/C");
list.add("dir");
pb = new ProcessBuilder(list);
pb.directory(new File("C:\\"));
p = pb.start();

stdout = new BufferedReader(new InputStreamReader(p
.getInputStream()));
while ((line = stdout.readLine()) != null) {
System.out.println(line);
}
stdout.close();

//echo the value of NAME
pb = new ProcessBuilder();
pb.command(new String[] {"CMD.exe", "/C", "echo %NAME%"});
pb.environment().put("NAME", "TEST");
p = pb.start();

stdout = new BufferedReader(new InputStreamReader(p
.getInputStream()));
while ((line = stdout.readLine()) != null) {
System.out.println(line);
}
stdout.close();
} catch (Exception e) {
e.printStackTrace();
}
}

從啟動其他程序的Java進程看,已啟動的其他程序輸出就是一個普通的輸入流,可以通過getInputStream()和getErrorStream來獲取。對於一般輸出文本的進程來說,可以將InputStream封裝成BufferedReader,然後就可以一行一行的對進程的標准輸出進行處理。
通常,一個程序/進程在執行結束後會向操作系統返回一個整數值,0一般代表執行成功,非0表示執行出現問題。有兩種方式可以用來獲取進程的返回值。一是利用waitFor(),該方法是阻塞的,執導進程執行完成後再返回。該方法返回一個代表進程返回值的整數值。另一個方法是調用exitValue()方法,該方法是非阻塞的,調用立即返回。但是如果進程沒有執行完成,則拋出異常。

Ⅸ 求助:一個簡單的java信息管理系統

你說的這些好麻煩的,倒是不難,但是包括設計資料庫,錄入數據,搭好框架,然後專業點的話用mvc結構、ssh框架寫好這個軟體,我估計。。。都值一些錢啦。這個不是一個小時兩個小時能做完的。高手也得僅一天吧。但是我認為高手是不會為了你的50分犧牲他的工作時間或者是休息時間的。
只能說你發錯地方啦,你到csdn上面看下有人能做嗎,或者是幫你設計一下資料庫。
估計不會有人幫你全部做完的。。。還是要自己動手啊。
希望我的回答能幫助你
如果自己做的過程中遇到問題,很願意幫助你

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:765
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:664
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:311
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:289
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:817
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:162
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:94
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:507
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:658
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:481