Back to project page AudioBook.
The source code is released under:
Creative Commons Legal Code Attribution-NonCommercial 3.0 Unported CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT C...
If you think the Android project AudioBook listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * This work is licensed under the Creative Commons Attribution-NonCommercial- * NoDerivs 3.0 Unported License. To view a copy of this license, visit * http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to * Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, * 94041, USA./* www. j av a 2 s. c om*/ * * Use of this work is permitted only in accordance with license rights granted. * Materials provided "AS IS"; no representations or warranties provided. * * Copyright ? 2012 Marcus Parkkinen, Aki K?kel?, Fredrik ?hs. **/ package edu.chalmers.dat255.audiobookplayer.util; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import android.content.Context; /** * @author Marcus Parkkinen, Aki K?kel? * @version 0.1 * */ public final class FileParser { private FileParser() { } // to defeat instantiation /** * Writes to internal storage given a file name. * * @param file * The file name to read from. * @param c * Context. * @param content * JSON String to be written. */ public static void writeToInternalStorage(String file, Context c, String content) throws IOException { FileOutputStream outputStream = c.openFileOutput(file, Context.MODE_PRIVATE); DataOutputStream dataOutputStream = new DataOutputStream(outputStream); dataOutputStream.writeUTF(content); dataOutputStream.close(); } /** * Reads from internal storage given a file name. * * @param file * The file name to read from. * @param c * Context. * @return JSON String to be read. */ public static String readFromInternalStorage(String file, Context c) throws IOException { FileInputStream inputStream = c.openFileInput(file); DataInputStream dataInputStream = new DataInputStream(inputStream); String result = dataInputStream.readUTF(); dataInputStream.close(); // return the JSON String representation of the object. return result; } }