If you think the Android project bitfynd-wallet-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright 2011-2014 the original author or authors.
*//fromwww.java2s.com
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/package de.schildbach.wallet.util;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.lang.reflect.Method;
import javax.annotation.Nonnull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Andreas Schildbach
*/publicclass Io
{
privatestaticfinal Logger log = LoggerFactory.getLogger(Io.class);
publicstaticfinallong copy(@Nonnull final Reader reader, @Nonnull final StringBuilder builder) throws IOException
{
return copy(reader, builder, 0);
}
publicstaticfinallong copy(@Nonnull final Reader reader, @Nonnull final StringBuilder builder, finallong maxChars) throws IOException
{
finalchar[] buffer = newchar[256];
long count = 0;
int n = 0;
while (-1 != (n = reader.read(buffer)))
{
builder.append(buffer, 0, n);
count += n;
if (maxChars != 0 && count > maxChars)
thrownew IOException("Read more than the limit of " + maxChars + " characters");
}
return count;
}
publicstaticfinallong copy(@Nonnull final InputStream is, @Nonnull final OutputStream os) throws IOException
{
finalbyte[] buffer = newbyte[1024];
long count = 0;
int n = 0;
while (-1 != (n = is.read(buffer)))
{
os.write(buffer, 0, n);
count += n;
}
return count;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
publicstaticvoid chmod(@Nonnull finalFile path, finalint mode)
{
try
{
final Class fileUtils = Class.forName("android.os.FileUtils");
final Method setPermissions = fileUtils.getMethod("setPermissions", String.class, int.class, int.class, int.class);
setPermissions.invoke(null, path.getAbsolutePath(), mode, -1, -1);
}
catch (final Exception x)
{
log.info("problem using undocumented chmod api", x);
}
}
}