Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Simmitive_Chris_Crook
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chris.crook
Simmitive_Chris_Crook
Commits
a1d8aadc
Commit
a1d8aadc
authored
Apr 06, 2021
by
chris.crook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
> adding load / save
parent
590901d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
11 deletions
+61
-11
MainActivity.java
.../java/com/example/summative_chris_crook/MainActivity.java
+61
-11
No files found.
app/src/main/java/com/example/summative_chris_crook/MainActivity.java
View file @
a1d8aadc
...
@@ -12,16 +12,37 @@ import java.io.FileWriter;
...
@@ -12,16 +12,37 @@ import java.io.FileWriter;
import
java.util.Scanner
;
import
java.util.Scanner
;
public
class
MainActivity
extends
AppCompatActivity
{
public
class
MainActivity
extends
AppCompatActivity
{
// file info and load
String
filename1
=
"magicwords"
;
String
filename1
=
"magicwords"
;
String
filename2
=
"appdatatxt"
;
String
filename2
=
"appdatatxt"
;
File
file1
;
File
file1
;
File
file2
;
File
file2
;
// generic variables and stuff
int
sizeoverride
=
1000
;
String
tempload
=
""
;
String
[]
[]
magicwords
=
new
String
[
sizeoverride
]
[
5
];
// storage of the login info
int
size
=
0
;
boolean
tempbool
=
true
;
int
tempint
=
0
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
file1
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename1
+
".txt"
);
file2
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename2
+
".txt"
);
file2
=
new
File
(
getApplicationContext
().
getFilesDir
(),
filename2
+
".txt"
);
for
(
int
i
=
0
;
i
<
sizeoverride
;
i
++){
magicwords
[
i
]
[
0
]
=
"END"
;
}
try
{
FileWriter
stream
=
new
FileWriter
(
file1
,
true
);
stream
.
append
(
""
);
//opens and test-loads an append
stream
.
close
();
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"write error"
,
Toast
.
LENGTH_SHORT
).
show
();
}
try
{
try
{
Scanner
reader
=
new
Scanner
(
file1
);
Scanner
reader
=
new
Scanner
(
file1
);
String
temp
=
""
;
String
temp
=
""
;
...
@@ -29,36 +50,65 @@ public class MainActivity extends AppCompatActivity {
...
@@ -29,36 +50,65 @@ public class MainActivity extends AppCompatActivity {
while
(
reader
.
hasNextLine
()){
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
temp
=
temp
+
reader
.
nextLine
();
}
}
Toast
.
makeText
(
getApplicationContext
(),
temp
+
" "
,
Toast
.
LENGTH_LONG
).
show
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_SHORT
).
show
();
try
{
}
FileWriter
stream
=
new
FileWriter
(
file1
,
false
);
tempload
=
openandload
();
stream
.
write
(
" "
);
if
(
tempload
.
equals
(
"&&&"
)){
stream
.
close
();
// this means that the load failed
}
}
catch
(
Exception
e
){
else
{
Toast
.
makeText
(
getApplicationContext
(),
"write error"
,
Toast
.
LENGTH_LONG
).
show
();
// load successful
if
(
tempload
.
equals
(
""
)){
// dont add a '#' to the start
}
}
else
{
tempload
+=
"#"
;
}
tempload
+=
"adminname&adminuser&adminpassword&ADMIN"
;
String
[]
temploadarray
=
tempload
.
split
(
"%"
);
size
=
temploadarray
.
length
;
for
(
int
i
=
0
;
i
<
size
;
i
++){
magicwords
[
i
]
[
0
]
=
temploadarray
[
i
];
// splits by user
}
for
(
int
i
=
0
;
i
<
size
;
i
++){
String
[]
sort
=
temploadarray
[
i
].
split
(
"&"
);
magicwords
[
i
]
[
1
]
=
sort
[
0
];
magicwords
[
i
]
[
2
]
=
sort
[
1
];
magicwords
[
i
]
[
3
]
=
sort
[
2
];
magicwords
[
i
]
[
4
]
=
sort
[
3
];
}
/*for (int i = 0; i < sizeoverride; i++){
if (magicwords [i] [0].equals("END")){
// end marker found
tempint = i;
break;
}
System.out.println(size + "");
System.out.println(tempint + "");
}*/
}
}
}
}
public
void
openandload
(
View
view
){
public
String
openandload
(
){
try
{
try
{
Scanner
reader
=
new
Scanner
(
file1
);
Scanner
reader
=
new
Scanner
(
file1
);
String
temp
=
""
;
String
temp
=
""
;
while
(
reader
.
hasNextLine
()){
while
(
reader
.
hasNextLine
()){
temp
=
temp
+
reader
.
nextLine
();
temp
=
temp
+
reader
.
nextLine
();
}
}
Toast
.
makeText
(
getApplicationContext
(),
temp
+
" "
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
temp
+
" "
,
Toast
.
LENGTH_LONG
).
show
();
return
temp
;
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
getApplicationContext
(),
"read error"
,
Toast
.
LENGTH_LONG
).
show
();
return
"&&&"
;
}
}
}
}
public
void
saveandclose
(
View
view
){
public
void
saveandclose
(){
try
{
try
{
FileWriter
stream
=
new
FileWriter
(
file1
,
false
);
FileWriter
stream
=
new
FileWriter
(
file1
,
false
);
stream
.
write
(
" "
);
stream
.
write
(
" "
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment