-
-
Save anta40/0676c5a26007d431740e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static synchronized String saveToFile(String basePath, byte[] data) | |
throws IOException { | |
try { | |
if (basePath.startsWith("file://")) { | |
// do nothing | |
} else if (!basePath.startsWith("/")) | |
basePath = "file:///" + basePath; | |
else if (basePath.startsWith("//")) | |
basePath = "file:/" + basePath; | |
else | |
basePath = "file://" + basePath; | |
FileConnection fconn = (FileConnection) Connector.open(basePath, | |
Connector.READ_WRITE); | |
if (!fconn.exists()) | |
fconn.create(); | |
fconn.setWritable(true); | |
OutputStream outputStream = fconn.openOutputStream(); | |
outputStream.write(data); | |
outputStream.close(); | |
fconn.close(); | |
return basePath; | |
} catch (IOException e) { | |
throw e; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment