use of java.io.CharArrayReader in project android_frameworks_base by ResurrectionRemix.
the class SettingsBackupAgent method restoreWifiSupplicant.
private void restoreWifiSupplicant(String filename, byte[] bytes, int size) {
try {
WifiNetworkSettings supplicantImage = new WifiNetworkSettings();
File supplicantFile = new File(FILE_WIFI_SUPPLICANT);
if (supplicantFile.exists()) {
// Retain the existing APs; we'll append the restored ones to them
BufferedReader in = new BufferedReader(new FileReader(FILE_WIFI_SUPPLICANT));
supplicantImage.readNetworks(in, null, true);
in.close();
supplicantFile.delete();
}
// Incorporate the restore AP information
if (size > 0) {
char[] restoredAsBytes = new char[size];
for (int i = 0; i < size; i++) restoredAsBytes[i] = (char) bytes[i];
BufferedReader in = new BufferedReader(new CharArrayReader(restoredAsBytes));
supplicantImage.readNetworks(in, null, false);
if (DEBUG_BACKUP) {
Log.v(TAG, "Final AP list:");
supplicantImage.dump();
}
}
// Install the correct default template
BufferedWriter bw = new BufferedWriter(new FileWriter(FILE_WIFI_SUPPLICANT));
copyWifiSupplicantTemplate(bw);
// Write the restored supplicant config and we're done
supplicantImage.write(bw);
bw.close();
} catch (IOException ioe) {
Log.w(TAG, "Couldn't restore " + filename);
}
}
use of java.io.CharArrayReader in project voltdb by VoltDB.
the class TestInMemoryJarfile method testReadFileFromJarfile.
/**
*
*/
public void testReadFileFromJarfile() throws IOException {
String catalog0 = this.m_catalog.serialize();
assertTrue(catalog0.length() > 0);
InMemoryJarfile jarfile = new InMemoryJarfile(m_jarPath.getAbsolutePath());
byte[] catalogBytes = jarfile.get(CatalogUtil.CATALOG_FILENAME);
String catalog1 = new String(catalogBytes, "UTF-8");
assertTrue(catalog1.length() > 0);
assertEquals(catalog0.length(), catalog1.length());
LineNumberReader reader0 = new LineNumberReader(new CharArrayReader(catalog0.toCharArray()));
LineNumberReader reader1 = new LineNumberReader(new CharArrayReader(catalog1.toCharArray()));
try {
int lines = 0;
while (reader0.ready()) {
assertEquals(reader0.ready(), reader1.ready());
assertEquals(reader0.readLine(), reader1.readLine());
lines++;
}
assertTrue(lines > 0);
reader0.close();
reader1.close();
} catch (Exception ex) {
ex.printStackTrace();
assertTrue(false);
}
}
use of java.io.CharArrayReader in project intellij-community by JetBrains.
the class CompactSyntaxLexerAdapter method start.
@Deprecated
public void start(char[] buffer, int startOffset, int endOffset, int initialState) {
myBuffer = new CharArrayCharSequence(buffer, startOffset, endOffset);
final CharArrayReader reader = new CharArrayReader(buffer, startOffset, endOffset - startOffset);
init(startOffset, endOffset, reader, initialState);
}
use of java.io.CharArrayReader in project jackrabbit by apache.
the class ClonedInputSource method cloneInputSource.
/**
* Make a clone if this input source. The input source being cloned is still
* valid after cloning.
*
* @return input source clone.
*/
public ClonedInputSource cloneInputSource() {
ClonedInputSource res = new ClonedInputSource(characterArray, byteArray);
res.setEncoding(getEncoding());
res.setPublicId(getPublicId());
res.setSystemId(getSystemId());
if (byteArray != null) {
res.setByteStream(new ByteArrayInputStream(byteArray));
}
if (characterArray != null) {
res.setCharacterStream(new CharArrayReader(characterArray));
}
return res;
}
use of java.io.CharArrayReader in project intellij-community by JetBrains.
the class ModelGen method loadXml.
public static Element loadXml(File configXml) throws Exception {
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new CharArrayReader(new char[0]));
}
});
final Document document = saxBuilder.build(configXml);
return document.getRootElement();
}
Aggregations