CHerry | Дата: Среда, 2011-09-21, 21:00:53 | Сообщение # 1 |
![CHerry](/avatar/97/8071-240618.gif) Генералиссимус
Группа: Администраторы
Сообщений: 141
Статус: Offline
| import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.ObjectInputStream;
public class test {
/** * @param args * @throws FileNotFoundException */ public static void main(String[] args) throws FileNotFoundException { // TODO Auto-generated method stub
int x = 45; int y = 0; try { x=x/y; x *=10; } // обработчик ошибок catch (Exception e) { System.out.println("Error-"+e ); System.out.println("Error-"+e.getMessage() ); e.printStackTrace();
// TODO: handle exception } finally { System.out.println("x="+x); }
//-------------Работа с файлами
try { FileInputStream fileName = new FileInputStream ("file.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fileName)); String strLine; while ((strLine = br.readLine())!= null) { System.out.println(strLine); }
}catch (Exception e) { // TODO: handle exception System.out.println(e); } {
} //--------------Тригонометрия double a = 45; double angle = Math.toRadians (a); System.out.println("angel="+angle);
System.out.println(java.lang.Math.cos(angle));
// ---------------Сериализация
InputStream in = new FileInputStream("test.java"); byte currentXMLByte[]= in.toString().getBytes(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLByte); while (byteArrayInputStream.read()!=-1) { System.out.println(byteArrayInputStream.read()); }
} // ДЗ посчитать слова (буквы) в файле // для уравнения рассмотерть разные исключения // найти модель UML диаграмм, ER диаграммы }
|
|
| |