-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.java
52 lines (50 loc) · 1.42 KB
/
file.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.io.*;
public class file
{
static void write()
{
try
{
String word="";
for(int i=1;i<=20;i++)
{
FileReader fr=new FileReader(System.getProperty("user.dir")+"\\popular.txt");
BufferedReader br=new BufferedReader(fr);
FileWriter fw = new FileWriter(System.getProperty("user.dir")+"\\"+i+".txt");
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
while((word=br.readLine())!=null)
if(word.length()==i)
pw.println(word);
pw.close();
bw.close();
fw.close();
br.close();
fr.close();
}
}
catch(Exception e)
{
System.out.println(e);
}
}
static void scan()
{
try
{
FileReader fr=new FileReader(System.getProperty("user.dir")+"\\popular.txt");
BufferedReader br=new BufferedReader(fr);
String big="a",word="";
while((word=br.readLine())!=null)
{
if(word.length()>big.length())
big=word;
}
System.out.println(big+" "+big.length());
}
catch(Exception e)
{
System.out.println(e);
}
}
}