-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileProcessing.java
More file actions
executable file
·90 lines (80 loc) · 2.36 KB
/
FileProcessing.java
File metadata and controls
executable file
·90 lines (80 loc) · 2.36 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.killmalware.bbsec;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import net.rim.device.api.i18n.SimpleDateFormat;
import net.rim.device.api.io.LineReader;
public class FileProcessing {
private static String logFileName(String filename)
{
Date dt = new Date();
SimpleDateFormat sfd = new SimpleDateFormat("dd-MM-yy");
return "file:///store/home/user/"+filename+sfd.formatLocal(dt.getTime())+".csv";
}
public static void Process (final String process)
{
}
public static void Write (String writemsg, String filename)
{
try //save to file
{
FileConnection conn = (FileConnection)Connector.open(logFileName(filename),Connector.READ_WRITE);
long x =0;
if (!conn.exists())
{
conn.create();
}
else
{
OutputStream out = conn.openOutputStream(x);
byte[] b = writemsg.getBytes();
if(conn.canWrite())
{
out.write(b);
}
else
{
System.out.println("Cannot write to this file");
out.close();
}
}
}
catch(Exception io)
{
System.out.println("exception" +io);
}
}
public static void Check (String raw, String filename)
{
try {
FileConnection conn = (FileConnection)Connector.open(logFileName(filename),Connector.READ_WRITE);
InputStream stream = conn.openInputStream();
LineReader lineReader = new LineReader(stream);
String line = new String(lineReader.readLine());
while(!line.equals("EOF"))
{
//compare
if(line.equals(raw))
{
Helpers.alertMsg("SMS sent twice!");
//write to log file
Write(line.toString(), "result");
break;
}
else
{
line = new String(lineReader.readLine());
}
}
stream.close();
stream = null;
}
catch(IOException e) {}
}
public void Log (String logmsg)
{
}
}