(模板)java文件读写与保留小数
2015-08-30 15:21
489 查看
import java.math.*; import java.text.*; import java.util.*; import java.io.*; public class Main { public static void main(String []args) throws IOException { Scanner cin = new Scanner(new File("trains.in")); PrintWriter cout = new PrintWriter(new File("trains.out")); double c = 3.155; BigDecimal t = BigDecimal.valueOf(3.155); java.text.DecimalFormat myFormat = new java.text.DecimalFormat("#.00"); cout.println(myFormat.format(t)); cin.close(); cout.close(); } }
相关文章推荐
- 在Ubuntu中安装Eclipse与创建桌面快捷方式
- 关于math.random运用的个人体会。
- 深入了解Java虚拟机读书笔记(一)JVM内存区域
- JAVA之JSON生成与解析
- 用Java实现的帧动画效果
- SpringMVC基础-@PathVariable
- JavaEE-01-温故(集合、泛型、io、多线程)&知新(junit、内省、路径问题)
- 关于Java--i++/++i问题
- The Java EE 6 Tutorial Maintaining Client State
- 【J2SE视频】-JDK安装
- java-- servlet获取资源的几种方式
- The Java EE 6 Tutorial Accessing the Web Context
- The Java EE 6 Tutorial Invoking Other Web Resources
- Java队列学习(一)
- Java Integer和int类型变量的两两相等性比较
- java的quoted-printable解码器源代码
- JAVA进阶路线图
- springmvc + freemarker 实现hello-world
- 搭建eclipse+github开发环境
- Java IO流->处理流->“随机访问” 的方式:RandomAccessFile