Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
f6265bb9
Commit
f6265bb9
authored
Sep 26, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FileUtils
parent
6ff05155
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
...le/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
+24
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/utils/FileUtils.java
View file @
f6265bb9
...
@@ -9,6 +9,8 @@ import androidx.annotation.Nullable;
...
@@ -9,6 +9,8 @@ import androidx.annotation.Nullable;
import
androidx.core.content.FileProvider
;
import
androidx.core.content.FileProvider
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.Closeable
;
import
java.io.Console
;
import
java.io.Console
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -25,7 +27,29 @@ import cn.garymb.ygomobile.Constants;
...
@@ -25,7 +27,29 @@ import cn.garymb.ygomobile.Constants;
public
class
FileUtils
{
public
class
FileUtils
{
public
static
void
closeQuietly
(
Closeable
closeable
)
{
if
(
closeable
!=
null
)
{
try
{
closeable
.
close
();
}
catch
(
Exception
ignored
)
{
}
}
}
public
static
String
readToString
(
String
fileName
)
throws
IOException
{
InputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
fileName
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
int
i
;
while
((
i
=
is
.
read
())
!=
-
1
)
{
baos
.
write
(
i
);
}
return
baos
.
toString
();
}
finally
{
closeQuietly
(
is
);
}
}
public
static
Uri
toUri
(
Context
context
,
File
file
)
{
public
static
Uri
toUri
(
Context
context
,
File
file
)
{
return
FileProvider
.
getUriForFile
(
context
,
context
.
getPackageName
()
+
".gamefiles"
,
file
);
return
FileProvider
.
getUriForFile
(
context
,
context
.
getPackageName
()
+
".gamefiles"
,
file
);
}
}
...
...
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