2010年4月30日 星期五

99/4/30 Java-型態轉換加總











import java.io.*;
import java.lang.Byte;
class Javaftirty
{
public static void main(String[] args)
{
int a,b,total;
System.out.println("Ming");
File mingfile = new File("mf.txt");
//Byte b = new Byte("1");
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
total=a+b;

try
{

FileOutputStream lym = new FileOutputStream(mingfile);
mingfile.createNewFile();
PrintStream lop = new PrintStream(lym);
lop.print(a +"+" + b + "=" + total);
//lym.write(b);
/*BufferedOutputStream yml = new BufferedOutputStream(lym);
PrintStream ps = new PrintStream(yml);
ps.println("12345");
ps.close();
lym.close();
yml.close();*/
}
catch (Exception e)
{
System.out.println("Ming");
}
}
}


資料來源
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html
http://www.tcrc.edu.tw/question/30.pdf
http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileOutputStream.html
http://java.sun.com/j2se/1.4.2/docs/api/java/io/BufferedOutputStream.html
http://java.sun.com/j2se/1.4.2/docs/api/java/io/PrintStream.html
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Byte.html

沒有留言:

張貼留言