唯一一道IO题
来源:互联网 发布:淘宝客网站建站 编辑:程序博客网 时间:2024/06/08 00:21
这是唯一一道IO题,能做出来说明已经把IO完全掌握了。
import java.io.*;
public class FileUtils{
public static String readFirstLine(String a){
FileReader f1 = null;
FileWriter out = null;
String sum = null;
try {
f1 = new FileReader(a);
out = new FileWriter(a);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader in = null;
BufferedWriter ou = new BufferedWriter(out);
try{
in = new BufferedReader(f1);
String x = in.readLine();
for(int i=0;i<x.length();i++){
sum=sum+x.substring(x.length()-i-1,x.length()-i);
}
ou.write(sum);
ou.flush();
}catch(Exception e){
}
return sum;
}
public static String readLine(String a,int b){
FileReader f1 = null;
FileWriter out = null;
try {
f1 = new FileReader(a);
out = new FileWriter(a);
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader in = null;
BufferedWriter ou = new BufferedWriter(out);
try{
in = new BufferedReader(f1);
String x = "";
for(int i=1;i<=b;i++){
if(b==i){
x=in.readLine();
}in.readLine();
}
String sum = null;
for(int i=0;i<x.length();i++){
sum=sum+x.substring(x.length()-i-1,x.length()-i);
}
ou.write(sum);
}catch(Exception e){
}
return a;
}
}
阅读全文
0 0
- 唯一一道IO题
- 字符串唯一前缀问题;一道Trie树笔试题;
- 针对一道笔试题线程+io流的练笔
- 一道JAVA IO面试题
- 一道JAVA IO面试题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 一道题
- 51nod 1675 序列变换(莫比乌斯反演)
- 怎样进行可行性研究?
- Window安装Nginx并设置为开机启动
- Android Path相关APIs
- 加密篇
- 唯一一道IO题
- Codeforces 499C:Crazy Town(计算几何)
- 训练日记-22
- 【基础知识整理】什么是启发式?
- What is d_type and why Docker overlayfs need it
- Linux中常用操作命令
- scala-2
- OPENGL—错误调试—无法解析外部符号
- Mahout安装与配置