func1 stringlengths 254 2.93k | func2 stringlengths 254 2.97k | label int64 0 1 |
|---|---|---|
public synchronized String encrypt(String plaintext) throws Exception {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
throw new Exception(e.getMessage());
}
try {
md.update(plai... | public String kodetu(String testusoila) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
new MezuLeiho("Ez da zifraketa algoritmoa aurkitu", "Ados", "Zifraketa Arazoa", JOptionPane.ERROR_MESSAGE);
... | 1 |
public static void compressWithZip(Vector fileList, String zipFileName) throws IOException {
if (fileList == null || fileList.size() == 0) return;
FileOutputStream fos = new FileOutputStream(zipFileName);
ZipOutputStream zos = new ZipOutputStream(fos);
Iterator iter = fileList.iterat... | public static void main(String[] args) throws Exception {
FileChannel fc = new FileOutputStream("data2.txt").getChannel();
fc.write(ByteBuffer.wrap("Some text".getBytes()));
fc.close();
fc = new FileInputStream("data2.txt").getChannel();
ByteBuffer buff = ByteBuffer.allocate(... | 1 |
private byte[] scramble411(String password, String seed) {
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");
byte[] passwordHashStage1 = md.digest(password.getBytes());
md.reset();
byte[] passwordHashStage2 = md.digest(passwordHashStage1... | private void getRandomGUID(boolean secure) {
MessageDigest md5 = null;
StringBuffer sbValueBeforeMD5 = new StringBuffer();
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
System.out.println("Error: " + e);
}
... | 1 |
private void readIntoList(URL url, Map<String, JMenuItem> list) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
int commandNameBegin = inputLine.indexO... | private String getEncoding() throws IOException {
BufferedReader reader = null;
String encoding = null;
try {
URLConnection connection = url.openConnection();
Map<String, List<String>> header = connection.getHeaderFields();
for (Map.Entry<String, List<Stri... | 1 |
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("usage: " + EvaluatorHelper.class.getName() + " <output> <data set file>");
System.exit(1);
}
Helper helper = Helper.getHelper(args[... | @Test
public void testCopy_inputStreamToOutputStream() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStreamTest(in);
ByteArrayOutputStream baout = new ByteArrayOutputStream();
OutputStream out = new YellOnFlushAndCloseOutputStreamT... | 1 |
protected String downloadURLtoString(URL url) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuffer sb = new StringBuffer(100 * 1024);
String str;
while ((str = in.readLine()) != null) {
sb.append(str);
... | public int read(String name) {
status = STATUS_OK;
try {
name = name.trim();
if (name.indexOf("://") > 0) {
URL url = new URL(name);
in = new BufferedInputStream(url.openStream());
} else {
in = new BufferedInputStre... | 1 |
private void copyResourceToFile(final String resourceFilename, final String destinationFilename) throws IOException {
InputStream inStream = null;
OutputStream outStream = null;
try {
inStream = MatsimResource.getAsInputStream(resourceFilename);
outStream = new FileOu... | private static void copy(String sourceName, String destName) throws IOException {
File source = new File(sourceName);
File dest = new File(destName);
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputSt... | 1 |
public static void main(String[] args) throws FileNotFoundException {
if (args.length < 2) throw new IllegalArgumentException();
String fnOut = args[args.length - 1];
PrintWriter writer = new PrintWriter(fnOut);
for (int i = 0; i < args.length - 1; i++) {
File fInput = ne... | private void copyFile(final String sourceFileName, final File path) throws IOException {
final File source = new File(sourceFileName);
final File destination = new File(path, source.getName());
FileChannel srcChannel = null;
FileChannel dstChannel = null;
try {
sr... | 1 |
private void copy(File source, File destinationDirectory) throws IOException {
if (source.isDirectory()) {
File newDir = new File(destinationDirectory, source.getName());
newDir.mkdir();
File[] children = source.listFiles();
for (int i = 0; i < children.length... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | 1 |
@Override
public String readFixString(final int len) {
if (len < 1) {
return StringUtils.EMPTY;
}
final StringWriter sw = new StringWriter();
try {
IOUtils.copy(createLimitedInputStream(len), sw, null);
} catch (IOException e) {
throw c... | private void bootKernel(String conf) {
try {
AssetManager am = getResources().getAssets();
InputStream is = am.open(conf + ".conf");
Properties props = new Properties();
props.load(is);
is.close();
Log.d("bootKernel", "Listing sdcard as... | 1 |
public String readPage(boolean ignoreComments) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
String html = "";
if (ignoreComments) {
while ((inputLine = in.readLine()) != null) {
if (i... | public Vector<String> getNetworkServersIPs(String netaddress) {
Vector<String> result = new Vector<String>();
boolean serverline = false;
String line;
String[] splitline;
try {
URL url = new URL(netaddress);
URLConnection connection = url.openConnectio... | 1 |
public BufferedWriter createOutputStream(String inFile, String outFile) throws IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
File ofp = new File(outFile);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(ofp));
... | public static File copyFile(File fileToCopy, File copiedFile) {
BufferedInputStream in = null;
BufferedOutputStream outWriter = null;
if (!copiedFile.exists()) {
try {
copiedFile.createNewFile();
} catch (IOException e1) {
e1.printStack... | 1 |
private static long copy(InputStream source, OutputStream sink) {
try {
return IOUtils.copyLarge(source, sink);
} catch (IOException e) {
logger.error(e.toString(), e);
throw new FaultException("System error copying stream", e);
} finally {
IOU... | public static void copyFile(File in, File out) throws Exception {
FileChannel sourceChannel = null;
FileChannel destinationChannel = null;
try {
sourceChannel = new FileInputStream(in).getChannel();
destinationChannel = new FileOutputStream(out).getChannel();
... | 1 |
private JSONObject executeHttpGet(String uri) throws Exception {
HttpGet req = new HttpGet(uri);
HttpClient client = new DefaultHttpClient();
HttpResponse resLogin = client.execute(req);
BufferedReader r = new BufferedReader(new InputStreamReader(resLogin.getEntity().getContent()));
... | public Vector<String> getNetworkServersIPs(String netaddress) {
Vector<String> result = new Vector<String>();
boolean serverline = false;
String line;
String[] splitline;
try {
URL url = new URL(netaddress);
URLConnection connection = url.openConnectio... | 1 |
static File copy(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
return out;
} c... | public static void main(String args[]) throws IOException {
String inFileName = args[0];
String outFileName = args[1];
long position = 0L;
try {
position = Long.parseLong(args[2]);
} catch (NumberFormatException nfex1) {
try {
position ... | 1 |
public static String encodePassword(String _originalPassword) {
MessageDigest md = null;
String encodedPassword = null;
try {
md = MessageDigest.getInstance("SHA-1");
md.update(_originalPassword.getBytes("UTF-8"));
encodedPassword = (new BASE64Encoder()).e... | public String kodetu(String testusoila) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
new MezuLeiho("Ez da zifraketa algoritmoa aurkitu", "Ados", "Zifraketa Arazoa", JOptionPane.ERROR_MESSAGE);
... | 1 |
public void createFile(File src, String filename) throws IOException {
try {
FileInputStream fis = new FileInputStream(src);
OutputStream fos = this.fileResourceManager.writeResource(this.txId, filename);
IOUtils.copy(fis, fos);
fos.close();
fis.cl... | public void logging() throws Fault {
final InterceptorWrapper wrap = new InterceptorWrapper(message);
final LoggingMessage buffer = new LoggingMessage("Inbound Message\n----------------------------");
String encoding = (String) wrap.getEncoding();
if (encoding != null) {
... | 1 |
public static URL addToArchive(Pod pod, ZipOutputStream podArchiveOutputStream, String filename, InputStream source) throws IOException {
ZipEntry entry = new ZipEntry(filename);
podArchiveOutputStream.putNextEntry(entry);
IOUtils.copy(source, podArchiveOutputStream);
podArchiveOutpu... | public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | 1 |
public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} catch (IOExcep... | public void patch() throws IOException {
if (mods.isEmpty()) {
return;
}
IOUtils.copy(new FileInputStream(Paths.getMinecraftJarPath()), new FileOutputStream(new File(Paths.getMinecraftBackupPath())));
JarFile mcjar = new JarFile(Paths.getMinecraftJarPath());
}
| 1 |
public String getmd5(String password) {
String pwHash = "";
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
md.reset();
md.update(password.getBytes());
byte[] b = md.digest();
for (int i = 0; i < b.length; i++)... | public static String hash(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] sha1hash = new byte[40];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
sha1hash = md.digest();
retu... | 1 |
public static void createTar(File directoryToPack, File targetTarFile) throws IOException {
if (directoryToPack == null) {
throw new NullPointerException("The parameter 'directoryToPack' must not be null");
}
if (targetTarFile == null) {
throw new NullPointerException... | protected File getFile() throws IOException {
File home = new File(System.getProperty("user.dir"));
String fileName = String.format("%s.txt", getFilePrefix());
File file = new File(home, fileName);
if (file.exists()) {
return file;
} else {
URL url = L... | 1 |
public static void main(String[] args) {
try {
boolean readExp = Utils.getFlag('l', args);
final boolean writeExp = Utils.getFlag('s', args);
final String expFile = Utils.getOption('f', args);
if ((readExp || writeExp) && (expFile.length() == 0)) {
... | private static void copy(String sourceName, String destName) throws IOException {
File source = new File(sourceName);
File dest = new File(destName);
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputSt... | 1 |
public String storeImage(InputStream inStream, String fileName, boolean resize) throws Exception {
Calendar rightNow = Calendar.getInstance();
String dayNamedFolderName = "" + rightNow.get(Calendar.YEAR) + StringUtil.getPaddedIntWithZeros(2, rightNow.get(Calendar.MONTH) + 1) + StringUtil.getPaddedIn... | public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | 1 |
public static void copyFile(String inFile, String outFile) {
File in = new File(inFile);
File out = new File(outFile);
try {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try ... | public boolean clonarFichero(FileInputStream rutaFicheroOrigen, String rutaFicheroDestino) {
System.out.println("");
boolean estado = false;
try {
FileOutputStream salida = new FileOutputStream(rutaFicheroDestino);
FileChannel canalOrigen = rutaFicheroOrigen.getChanne... | 1 |
public static byte[] hash(final byte[] saltBefore, final String content, final byte[] saltAfter, final int repeatedHashingCount) throws NoSuchAlgorithmException, UnsupportedEncodingException {
if (content == null) return null;
final MessageDigest digest = MessageDigest.getInstance(DIGEST);
i... | @Digester(forField = "password")
public static String encriptPassword(String passwd) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(passwd.getBytes());
BigInteger hash = new BigInteger(1, md.digest());
return hash.toString(16);
... | 1 |
private void copy(File source, File destinationDirectory) throws IOException {
if (source.isDirectory()) {
File newDir = new File(destinationDirectory, source.getName());
newDir.mkdir();
File[] children = source.listFiles();
for (int i = 0; i < children.length... | public static void copy(String fromFile, String toFile) throws IOException {
File inputFile = new File(fromFile);
File outputFile = new File(toFile);
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) ... | 1 |
public ByteBuffer[] write(ByteBuffer[] byteBuffers) {
if (!m_sslInitiated) {
return m_writer.write(byteBuffers);
}
if (m_engine.getHandshakeStatus() != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) {
if (!NIOUtils.isEmpty(byteBuffers)) {
m_initialOu... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | 1 |
@Override
public Resource createNew(String name, InputStream in, Long length, String contentType) throws IOException {
File dest = new File(this.realFile, name);
if (allowedClient) {
if (".request".equals(name) || ".tokens".equals(name)) {
FileOutputStream out = null;... | public static void saveFileData(File file, File destination, java.io.File newDataFile) throws Exception {
String fileName = file.getFileName();
String assetsPath = FileFactory.getRealAssetsRootPath();
new java.io.File(assetsPath).mkdir();
java.io.File workingFile = getAssetIOFile(fil... | 1 |
public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | public static void copy(File in, File out) throws IOException {
if (in.exists() && in != null && out != null) {
if (!out.exists()) {
if (in.isDirectory()) {
out.mkdirs();
} else {
out.createNewFile();
}
... | 1 |
protected void truncate(final File file) {
LogLog.debug("Compression of file: " + file.getAbsolutePath() + " started.");
if (FileUtils.isFileOlder(file, ManagementFactory.getRuntimeMXBean().getStartTime())) {
final File backupRoot = new File(this.getBackupDir());
if (!backupR... | private void copy(File inputFile, File outputFile) throws Exception {
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
out.close();
... | 1 |
private void extractZipFile(String filename, JTextPane progressText) throws IOException {
String destinationname = "";
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(filename));
... | public static boolean copyTextFile(File src, File dst) {
try {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(src));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dst));
byte[] buf = new byte[1024];
int readsiz... | 1 |
public static void copyFile(File in, File out) throws IOException {
FileChannel sourceChannel = new FileInputStream(in).getChannel();
FileChannel destinationChannel = new FileOutputStream(out).getChannel();
sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
source... | public void extractImage(String input, String output, DjatokaDecodeParam params, IWriter w) throws DjatokaException {
File in = null;
String dest = output;
if (input.equals(STDIN)) {
try {
in = File.createTempFile("tmp", ".jp2");
input = in.getAbso... | 1 |
public static void copyOverWarFile() {
System.out.println("Copy Over War File:");
File dir = new File(theAppsDataDir);
FileFilter ff = new WildcardFileFilter("*.war");
if (dir.listFiles(ff).length == 0) {
dir = new File(System.getProperty("user.dir") + "/war");
... | public void cpFile(File source, File target, boolean replace, int bufferSize) throws IOException {
if (!source.exists()) throw new IOException("source file not exists");
if (!source.isFile()) throw new IOException("source file not exists(is a directory)");
InputStream src = new FileInputStre... | 1 |
public BufferedWriter createOutputStream(String inFile, String outFile) throws IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
File ofp = new File(outFile);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(ofp));
... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | 1 |
private void doFinishLoadAttachment(long attachmentId) {
if (attachmentId != mLoadAttachmentId) {
return;
}
Attachment attachment = Attachment.restoreAttachmentWithId(MessageView.this, attachmentId);
Uri attachmentUri = AttachmentProvider.getAttachmentUri(mAccountId, atta... | @Override
public void trainClassifier(File dir, String... args) throws Exception {
String[] command = new String[args.length + 3];
command[0] = this.getCommand();
System.arraycopy(args, 0, command, 1, args.length);
command[command.length - 2] = new File(dir, "training-data.libsvm... | 1 |
private void copyResource() throws Exception {
URL url = getResource(source);
InputStream input;
if (url != null) {
input = url.openStream();
} else if (new File(source).exists()) {
input = new FileInputStream(source);
} else {
throw new Ex... | public static void copyOverWarFile() {
System.out.println("Copy Over War File:");
File dir = new File(theAppsDataDir);
FileFilter ff = new WildcardFileFilter("*.war");
if (dir.listFiles(ff).length == 0) {
dir = new File(System.getProperty("user.dir") + "/war");
... | 1 |
@Override
public String getMessageDigest() throws SarasvatiLoadException {
if (messageDigest == null) {
Collections.sort(nodes);
Collections.sort(externals);
try {
MessageDigest digest = MessageDigest.getInstance("SHA1");
digest.update(... | public String digest(String message) throws NoSuchAlgorithmException, EncoderException {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(message.getBytes());
byte[] raw = messageDigest.digest();
byte[] chars = new Base64().encode(raw);
... | 1 |
public BufferedWriter createOutputStream(String inFile, String outFile) throws IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
File ofp = new File(outFile);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(ofp));
... | public void execute(File sourceFile, File destinationFile, String conversionType, Properties java2HtmlConfig) {
FileReader reader = null;
Writer writer = null;
try {
reader = new FileReader(sourceFile);
logger.info("Using source file: " + trimPath(userDir, sourceFile)... | 1 |
public static void copyFile(File from, File to) throws IOException {
assert (from != null);
assert (to != null);
if (!to.exists()) {
File parentDir = to.getParentFile();
if (!parentDir.exists()) parentDir.mkdirs();
to.createNewFile();
}
Fil... | public void test() throws Exception {
StorageStringWriter s = new StorageStringWriter(2048, "UTF-8");
s.addText("Test");
try {
s.getOutputStream();
fail("Should throw IOException as method not supported.");
} catch (IOException e) {
}
s.getWrit... | 1 |
private static void copyFile(File in, File out) {
try {
FileChannel sourceChannel = new FileInputStream(in).getChannel();
FileChannel destinationChannel = new FileOutputStream(out).getChannel();
sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
... | public void logging() throws Fault {
final InterceptorWrapper wrap = new InterceptorWrapper(message);
final LoggingMessage buffer = new LoggingMessage("Inbound Message\n----------------------------");
String encoding = (String) wrap.getEncoding();
if (encoding != null) {
... | 1 |
public static void main(String[] argv) {
if (1 < argv.length) {
File[] sources = Source(argv[0]);
if (null != sources) {
for (File src : sources) {
File[] targets = Target(src, argv);
if (null != targets) {
... | public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | 1 |
protected ExternalDecoder(InputStream source, Process process) {
super(source);
this.process = process;
this.processStdOut = process.getInputStream();
this.processStdIn = process.getOutputStream();
new Thread() {
@Override
public void run() {
... | public static File copyFile(File fileToCopy, File copiedFile) {
BufferedInputStream in = null;
BufferedOutputStream outWriter = null;
if (!copiedFile.exists()) {
try {
copiedFile.createNewFile();
} catch (IOException e1) {
e1.printStack... | 1 |
private void loadDDL() throws IOException {
try {
conn.createStatement().executeQuery("SELECT * FROM overrides").close();
} catch (SQLException e) {
Statement stmt = null;
if (!e.getMessage().startsWith(ERR_MISSING_TABLE)) {
LOG.fatal(SQL_ERROR, e)... | public void removeRealm(final List<Integer> realmIds) {
try {
connection.setAutoCommit(false);
new ProcessEnvelope().executeNull(new ExecuteProcessAbstractImpl(connection, false, false, true, true) {
@Override
public void executeProcessReturnNull() th... | 1 |
protected static void copyDeleting(File source, File dest) throws IOException {
byte[] buf = new byte[8 * 1024];
FileInputStream in = new FileInputStream(source);
try {
FileOutputStream out = new FileOutputStream(dest);
try {
int count;
... | public static void createTar(File directoryToPack, File targetTarFile) throws IOException {
if (directoryToPack == null) {
throw new NullPointerException("The parameter 'directoryToPack' must not be null");
}
if (targetTarFile == null) {
throw new NullPointerException... | 1 |
private void updateFile(File file) throws FileNotFoundException, IOException {
File destFile = new File(file.getPath().replace(URL_UNZIPPED_PREFIX + latestVersion, ""));
FileChannel in = null;
FileChannel out = null;
try {
if (!destFile.exists()) {
destFil... | private void extractZipFile(String filename, JTextPane progressText) throws IOException {
String destinationname = "";
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(filename));
... | 1 |
public BufferedWriter createOutputStream(String inFile, String outFile) throws IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
File ofp = new File(outFile);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(ofp));
... | public static boolean decodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | 1 |
public static void DecodeMapFile(String mapFile, String outputFile) throws Exception {
byte magicKey = 0;
byte[] buffer = new byte[2048];
int nread;
InputStream map;
OutputStream output;
try {
map = new FileInputStream(mapFile);
} catch (Exception ... | public static void copyFile(File src, File dst) throws IOException {
try {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[TEMP_FILE_BUFFER_SIZE];
int len;
while ((len = in.read(buf)) >... | 1 |
protected boolean doRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String path = request.getPathInfo();
if (!path.startsWith(alias)) {
throw new ServletException("Path '" + path + "' does not start with registered alias '" + alias... | public void patch() throws IOException {
if (mods.isEmpty()) {
return;
}
IOUtils.copy(new FileInputStream(Paths.getMinecraftJarPath()), new FileOutputStream(new File(Paths.getMinecraftBackupPath())));
JarFile mcjar = new JarFile(Paths.getMinecraftJarPath());
}
| 1 |
public String storeImage(InputStream inStream, String fileName, boolean resize) throws Exception {
Calendar rightNow = Calendar.getInstance();
String dayNamedFolderName = "" + rightNow.get(Calendar.YEAR) + StringUtil.getPaddedIntWithZeros(2, rightNow.get(Calendar.MONTH) + 1) + StringUtil.getPaddedIn... | public static void copy(File source, File destination) throws FileNotFoundException, IOException {
if (source == null) throw new NullPointerException("The source may not be null.");
if (destination == null) throw new NullPointerException("The destination may not be null.");
FileInputStream s... | 1 |
private void callService() {
try {
URL url = new URL(baseUrl + servicePath + attributes);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
StringBuffer buf = new StringBuffer();
while ((inputLine = ... | public final int wordFrequency(String word) {
String replWebQuery = webQuery.replaceFirst("WORDREPLACE", word);
try {
URL url = new URL(replWebQuery);
String content = url.toString();
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));... | 1 |
public static void copyFromFileToFileUsingNIO(File inputFile, File outputFile) throws FileNotFoundException, IOException {
FileChannel inputChannel = new FileInputStream(inputFile).getChannel();
FileChannel outputChannel = new FileOutputStream(outputFile).getChannel();
try {
inpu... | public static void copyFile(File src, File dest) throws IOException {
FileInputStream fis = new FileInputStream(src);
FileOutputStream fos = new FileOutputStream(dest);
java.nio.channels.FileChannel channelSrc = fis.getChannel();
java.nio.channels.FileChannel channelDest = fos.getCha... | 1 |
public static String createPseudoUUID() {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(new UID().toString().getBytes());
try {
String localHost = InetAddress.getLocalHost().toString();
messageDi... | static String calculateProfileDiffDigest(String profileDiff, boolean normaliseWhitespace) throws Exception {
if (normaliseWhitespace) {
profileDiff = removeWhitespaces(profileDiff);
}
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(profileDiff.getBytes());
... | 1 |
public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | public BufferedWriter createOutputStream(String inFile, String outFile) throws IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
File ofp = new File(outFile);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(ofp));
... | 1 |
public void modifyApplicationMessage(String locale, String messageName, String messageValue) {
Properties properties = new Properties();
try {
String i18nPath = ServerUtil.removelastResourceURL(ConfigurationServiceImpl.class.getResource("/es/ua/tranube/prototype/main/client/TranubeConsta... | public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: GZip source");
return;
}
String zipname = args[0] + ".gz";
GZIPOutputStream zipout;
try {
FileOutputStream out = new FileOutputStream(zipname);
... | 1 |
public static void makeBackup(File dir, String sourcedir, String destinationdir, String destinationDirEnding) {
String[] files;
files = dir.list();
File checkdir = new File(destinationdir + System.getProperty("file.separator") + destinationDirEnding);
if (!checkdir.isDirectory()) {
... | public static void copy(File source, File destination) throws FileNotFoundException, IOException {
if (source == null) throw new NullPointerException("The source may not be null.");
if (destination == null) throw new NullPointerException("The destination may not be null.");
FileInputStream s... | 1 |
private static String encode(final String input) throws UnsupportedEncodingException, NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.reset();
md.update(input.getBytes("UTF-8"));
return toHexString(md.digest());
}
| public static String getMessageDigest(String input) {
if (input == null) {
log.warn("Returning SHA-1 null value for null input");
return null;
}
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(input.getBytes("UTF-8"));
... | 1 |
@Test
public void testIdentification() {
try {
String username = "muchu";
String password = "123";
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(password.getBytes());
LogService logServiceMock = EasyMock.createMock(LogService... | @Override
public User saveUser(User user) {
try {
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(user.getPassword().getBytes("UTF-8"));
byte[] hash = digest.digest();
BigInteger bigInt = new BigInteger(1, hash);
... | 1 |
private void CopyTo(File dest) throws IOException {
FileReader in = null;
FileWriter out = null;
int c;
try {
in = new FileReader(image);
out = new FileWriter(dest);
while ((c = in.read()) != -1) out.write(c);
} finally {
if (in... | private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if (destFile.exists() && destFile.isDirectory()) {
throw new IOException("Destination '" + destFile + "' exists but is a directory");
}
FileChannel input = new FileInputStre... | 1 |
private void doFinishLoadAttachment(long attachmentId) {
if (attachmentId != mLoadAttachmentId) {
return;
}
Attachment attachment = Attachment.restoreAttachmentWithId(MessageView.this, attachmentId);
Uri attachmentUri = AttachmentProvider.getAttachmentUri(mAccountId, atta... | public int run(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Download dir local");
return 1;
}
OutputStream out = new FileOutputStream(args[1]);
Path srcDir = new Path(args[0]);
Configuration conf = new Configuration();
... | 1 |
public static String getUniqueKey() {
String digest = "";
try {
final MessageDigest md = MessageDigest.getInstance("MD5");
final String timeVal = "" + (System.currentTimeMillis() + 1);
String localHost = "";
try {
localHost = InetAddres... | public static byte[] getSystemStateHash() {
MessageDigest sha1;
try {
sha1 = MessageDigest.getInstance("SHA1");
} catch (Exception e) {
throw new Error("Error in RandomSeed, no sha1 hash");
}
sha1.update((byte) System.currentTimeMillis());
sha1... | 1 |
public void createFile(File src, String filename) throws IOException {
try {
FileInputStream fis = new FileInputStream(src);
OutputStream fos = this.fileResourceManager.writeResource(this.txId, filename);
IOUtils.copy(fis, fos);
fos.close();
fis.cl... | public static boolean copyTextFile(File src, File dst) {
try {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(src));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dst));
byte[] buf = new byte[1024];
int readsiz... | 1 |
public void testSimpleQuery() throws Exception {
JCRNodeSource dummySource = (JCRNodeSource) resolveSource(BASE_URL + "users/alexander.klimetschek");
assertNotNull(dummySource);
OutputStream os = ((ModifiableSource) dummySource).getOutputStream();
assertNotNull(os);
String du... | private void copyIconFiles(UmlClass clazz) {
if (clazz.hasAnnotation("icon16")) {
String i16 = clazz.annotationValue("icon16");
String fileType = ".png";
if (i16.endsWith(".jpg")) fileType = ".jpg";
if (i16.endsWith(".gif")) fileType = ".gif";
Stri... | 1 |
public static String hashStringMD5(String string) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(string.getBytes());
byte byteData[] = md.digest();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < byteData.length; i++... | @Primitive
public static Value caml_md5_string(final CodeRunner ctxt, final Value str, final Value ofs, final Value len) throws Fail.Exception {
try {
final MessageDigest md5 = MessageDigest.getInstance(Md5.ALGO);
md5.update(str.asBlock().getBytes(), ofs.asLong(), len.asLong());
... | 1 |
public static void copyExternalResource(File sourceFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile)... | public static void copy(File source, File destination) throws FileNotFoundException, IOException {
if (source == null) throw new NullPointerException("The source may not be null.");
if (destination == null) throw new NullPointerException("The destination may not be null.");
FileInputStream s... | 1 |
public static String retrieveQ(String urlToRetrieve) throws MalformedURLException, IOException {
URL url = new URL(urlToRetrieve);
URLConnection uc = url.openConnection();
InputStream is = uc.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is));
... | private String File2String(String directory, String filename) {
String line;
InputStream in = null;
try {
File f = new File(filename);
System.out.println("File On:>>>>>>>>>> " + f.getCanonicalPath());
in = new FileInputStream(f);
} catch (FileNotFo... | 1 |
public void doBody(JWebLiteRequestWrapper req, JWebLiteResponseWrapper resp) throws SkipException {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(this.loadData(req)));
bos = new BufferedOutputS... | private void copyFile(final String sourceFileName, final File path) throws IOException {
final File source = new File(sourceFileName);
final File destination = new File(path, source.getName());
FileChannel srcChannel = null;
FileChannel dstChannel = null;
try {
sr... | 1 |
protected void createSettingsIfNecessary() throws IOException {
OutputStream out = null;
try {
final File fSettings = SettingsUtils.getSettingsFile();
if (!fSettings.exists()) {
fSettings.createNewFile();
final Path src = new Path("mvn/settings... | public static void main(String[] args) throws Exception {
FileChannel fc = new FileOutputStream("data2.txt").getChannel();
fc.write(ByteBuffer.wrap("Some text".getBytes()));
fc.close();
fc = new FileInputStream("data2.txt").getChannel();
ByteBuffer buff = ByteBuffer.allocate(... | 1 |
public void updateUser(User portalUserBean, AuthSession authSession) {
DatabaseAdapter dbDyn = null;
PreparedStatement ps = null;
try {
dbDyn = DatabaseAdapter.getInstance();
String sql = "update WM_LIST_USER " + "set FIRST_NAME=?,MIDDLE_NAME=?,LAST_NAME=?, " + " ... | public void deleteAuthors() throws Exception {
if (proposalIds.equals("") || usrIds.equals("")) throw new Exception("No proposal or author selected.");
String[] pids = proposalIds.split(",");
String[] uids = usrIds.split(",");
int pnum = pids.length;
int unum = uids.length;
... | 1 |
public static String SHA1(String text) {
byte[] sha1hash = new byte[40];
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(text.getBytes("iso-8859-1"), 0, text.length());
sha1hash = md.digest();
} catch (UnsupportedEncodingException ex... | private static String encrypt(String algorithm, String password, Long digestSeed) {
try {
MessageDigest digest = MessageDigest.getInstance(algorithm);
digest.reset();
digest.update(password.getBytes("UTF-8"));
digest.update(digestSeed.toString().getBytes("UTF-... | 1 |
public static void main(String[] args) {
try {
boolean readExp = Utils.getFlag('l', args);
final boolean writeExp = Utils.getFlag('s', args);
final String expFile = Utils.getOption('f', args);
if ((readExp || writeExp) && (expFile.length() == 0)) {
... | private void internalCopy(File fSource, File file) throws FileNotFoundException, IOException {
if (fSource.getName().equals("Thums.db")) return;
System.out.println("copying " + fSource + " in " + file);
OutputStream o = new BufferedOutputStream(new FileOutputStream(file));
... | 1 |
@Override
public void makeRead(final String user, final long databaseID, final long time) throws SQLException {
final String query = "insert into fs.read_post (post, user, read_date) values (?, ?, ?)";
ensureConnection();
final PreparedStatement statement = m_connection.prepareStatement(... | public boolean setUpdateCliente(int IDcliente, String nombre, String paterno, String materno, String ocupacion, String rfc) {
boolean update = false;
try {
stm = conexion.prepareStatement("update clientes set nombre='" + nombre.toUpperCase().trim() + "' , paterno='" + paterno.toUpperCase... | 1 |
public BufferedWriter createOutputStream(String inFile, String outFile) throws IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
File ofp = new File(outFile);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(ofp));
... | protected boolean doRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String path = request.getPathInfo();
if (!path.startsWith(alias)) {
throw new ServletException("Path '" + path + "' does not start with registered alias '" + alias... | 1 |
public static URL addToArchive(Pod pod, ZipOutputStream podArchiveOutputStream, String filename, InputStream source) throws IOException {
ZipEntry entry = new ZipEntry(filename);
podArchiveOutputStream.putNextEntry(entry);
IOUtils.copy(source, podArchiveOutputStream);
podArchiveOutpu... | private void compress(String outputFile, ArrayList<String> inputFiles, PrintWriter log, boolean compress) throws Exception {
String absPath = getAppConfig().getPathConfig().getAbsoluteServerPath();
log.println("Concat files into: " + outputFile);
OutputStream out = new FileOutputStream(absPa... | 1 |
@Override
public void sendErrorMessage(String message) throws EntriesException, StatementNotExecutedException, NotConnectedException, MessagingException {
if (query == null) {
throw new NotConnectedException();
}
ArrayList<String> recipients = query.getUserManager().getTecMai... | public static void copyFile(File src, File dst) throws IOException {
try {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[TEMP_FILE_BUFFER_SIZE];
int len;
while ((len = in.read(buf)) >... | 1 |
public static void copyFile(File from, File to) throws IOException {
assert (from != null);
assert (to != null);
if (!to.exists()) {
File parentDir = to.getParentFile();
if (!parentDir.exists()) parentDir.mkdirs();
to.createNewFile();
}
Fil... | private String transferWSDL(String wsdlURL, String userPassword) throws WiseConnectionException {
String filePath = null;
try {
URL endpoint = new URL(wsdlURL);
HttpURLConnection conn = (HttpURLConnection) endpoint.openConnection();
conn.setDoOutput(false);
... | 1 |
void addDataFromURL(URL theurl) {
String line;
InputStream in = null;
try {
in = theurl.openStream();
BufferedReader data = new BufferedReader(new InputStreamReader(in));
while ((line = data.readLine()) != null) {
thetext.append(line + "\n"... | public static String getContent(HttpUriRequest request) throws Exception {
StringBuffer sb = new StringBuffer();
HttpClient client = new DefaultHttpClient();
HttpParams httpParams = client.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 30000);
HttpConnecti... | 1 |
static void copyFile(File in, File out) throws IOException {
FileChannel source = new FileInputStream(in).getChannel();
FileChannel destination = new FileOutputStream(out).getChannel();
source.transferTo(0, source.size(), destination);
source.close();
destination.close();
... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | 1 |
public static String getWebPage(URL urlObj) {
try {
String content = "";
InputStreamReader is = new InputStreamReader(urlObj.openStream());
BufferedReader reader = new BufferedReader(is);
String line;
while ((line = reader.readLine()) != null) {
... | public static void doVersionCheck(View view) {
view.showWaitCursor();
try {
URL url = new URL(jEdit.getProperty("version-check.url"));
InputStream in = url.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
String line;
... | 1 |
public void createFile(File src, String filename) throws IOException {
try {
FileInputStream fis = new FileInputStream(src);
OutputStream fos = this.fileResourceManager.writeResource(this.txId, filename);
IOUtils.copy(fis, fos);
fos.close();
fis.cl... | public static void copyFileChannel(File src, File dst, boolean preserveModificationTime) throws IOException {
FileChannel inputChannel = null;
FileChannel outputChannel = null;
long length = 0;
try {
inputChannel = new FileInputStream(src).getChannel();
length... | 1 |
public static void main(String[] args) {
String source, destination;
if (args[0].toLowerCase().endsWith(".gz")) {
source = args[0];
destination = source.substring(0, source.length() - 3);
} else {
source = args[0] + ".gz";
destination = args[0]... | public String execute() {
String dir = "E:\\ganymede_workspace\\training01\\web\\user_imgs\\";
HomeMap map = new HomeMap();
map.setDescription(description);
Integer id = homeMapDao.saveHomeMap(map);
FileOutputStream fos;
try {
fos = new FileOutputStream(di... | 1 |
private void forBundle(BundleManipulator manip) {
ByteArrayOutputStream bout = null;
try {
bout = new ByteArrayOutputStream();
ZipOutputStream zout = new ZipOutputStream(bout);
Bundle bundle = getBundle();
Enumeration<URL> files = bundle.findEntries("/... | private static void copyFile(File source, File dest) throws IOException {
FileChannel srcChannel = new FileInputStream(source).getChannel();
FileChannel dstChannel = new FileOutputStream(dest).getChannel();
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
srcChannel.close()... | 1 |
public synchronized String encrypt(String plaintext) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = null;
md = MessageDigest.getInstance("SHA");
md.update(plaintext.getBytes("UTF-8"));
byte raw[] = md.digest();
String hash = (new BASE64Enco... | public static byte[] getSystemStateHash() {
MessageDigest sha1;
try {
sha1 = MessageDigest.getInstance("SHA1");
} catch (Exception e) {
throw new Error("Error in RandomSeed, no sha1 hash");
}
sha1.update((byte) System.currentTimeMillis());
sha1... | 1 |
public static void copyFile(File in, File out) throws IOException {
FileChannel sourceChannel = new FileInputStream(in).getChannel();
FileChannel destinationChannel = new FileOutputStream(out).getChannel();
sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
source... | public static void main(String[] args) throws FileNotFoundException {
if (args.length < 2) throw new IllegalArgumentException();
String fnOut = args[args.length - 1];
PrintWriter writer = new PrintWriter(fnOut);
for (int i = 0; i < args.length - 1; i++) {
File fInput = ne... | 1 |
public static void gzip() throws Exception {
System.out.println("gzip()");
GZIPOutputStream zipout = new GZIPOutputStream(new FileOutputStream("/zip/myzip.gz"));
byte buffer[] = new byte[BLOCKSIZE];
File dir = new File("/zip/covers");
System.out.println("Dir '" + dir.getAbsol... | public static void copy(File source, File destination) throws FileNotFoundException, IOException {
if (source == null) throw new NullPointerException("The source may not be null.");
if (destination == null) throw new NullPointerException("The destination may not be null.");
FileInputStream s... | 1 |
@TestProperties(name = "Simple test for adding different image files to report as link")
public void testAddLinkToImage() throws Exception {
InputStream in = this.getClass().getClassLoader().getResourceAsStream("regression/generic/images/splash.jpg");
report.report(report.getCurrentTestFolder() ... | private static void copyFiles(String strPath, String dstPath) throws Exception {
File src = new File(strPath);
File dest = new File(dstPath);
if (src.isDirectory()) {
dest.mkdirs();
String list[] = src.list();
for (int i = 0; i < list.length; i++) {
... | 1 |
public void doBody(JWebLiteRequestWrapper req, JWebLiteResponseWrapper resp) throws SkipException {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(this.loadData(req)));
bos = new BufferedOutputS... | private static void copyFile(File src, File dst) throws IOException {
FileChannel in = new FileInputStream(src).getChannel();
FileChannel out = new FileOutputStream(dst).getChannel();
in.transferTo(0, in.size(), out);
in.close();
out.close();
}
| 1 |
private static File getZipAsFile(DigitalObject digOb) {
String folderName = randomizeFileName(getFolderNameFromDigObject(digOb));
File tmpFolder = new File(utils_tmp, folderName);
File zip = null;
try {
FileUtils.forceMkdir(tmpFolder);
zip = new File(tmpFolder... | public static void copyFileChannel(File src, File dst, boolean preserveModificationTime) throws IOException {
FileChannel inputChannel = null;
FileChannel outputChannel = null;
long length = 0;
try {
inputChannel = new FileInputStream(src).getChannel();
length... | 1 |
private String hashPassword(String password) throws NoSuchAlgorithmException {
String hash = null;
MessageDigest md = MessageDigest.getInstance("SHA");
log.debug("secure hash on password " + password);
md.update(password.getBytes());
hash = new String(Base64.encodeBase64(md.d... | public static String digest(String algorithm, String text) {
MessageDigest mDigest = null;
try {
mDigest = MessageDigest.getInstance(algorithm);
mDigest.update(text.getBytes(ENCODING));
} catch (NoSuchAlgorithmException nsae) {
_log.error(nsae, nsae);
... | 1 |
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: GZip source");
return;
}
String zipname = args[0] + ".gz";
GZIPOutputStream zipout;
try {
FileOutputStream out = new FileOutputStream(zipname);
... | public void test() throws Exception {
StorageStringWriter s = new StorageStringWriter(2048, "UTF-8");
s.addText("Test");
try {
s.getOutputStream();
fail("Should throw IOException as method not supported.");
} catch (IOException e) {
}
s.getWrit... | 1 |
public TableDirectory(RandomAccessFile raf) throws IOException {
version = raf.readInt();
numTables = raf.readShort();
searchRange = raf.readShort();
entrySelector = raf.readShort();
rangeShift = raf.readShort();
entries = new DirectoryEntry[numTables];
for (i... | public static int[] sortstring(int[] a1) {
int temp;
for (int j = 0; j < (a1.length * a1.length); j++) {
for (int i = 0; i < a1.length - 1; i++) {
if (a1[i] > a1[i + 1]) {
temp = a1[i];
a1[i] = a1[i + 1];
a1[i + ... | 1 |
public static String generateHash(String key) {
key += "use_your_key_here";
MessageDigest md;
try {
md = java.security.MessageDigest.getInstance("MD5");
md.reset();
md.update(key.getBytes());
byte[] bytes = md.digest();
StringBuffer... | public static String md5(String message, boolean base64) {
MessageDigest md5 = null;
String digest = message;
try {
md5 = MessageDigest.getInstance("MD5");
md5.update(message.getBytes());
byte[] digestData = md5.digest();
if (base64) {
... | 1 |
private void copy(File inputFile, File outputFile) throws Exception {
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
out.close();
... | public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | 1 |
public static void writeFileType(String uriFile, String outputfile, int num) {
BufferedWriter writer = null;
String uri = null;
try {
int counter = 1;
writer = new BufferedWriter(new FileWriter(outputfile));
BufferedReader reader = new BufferedReader(new F... | public static String getURLContent(String urlToSearchString) throws IOException {
URL url = new URL(urlToSearchString);
URLConnection conn = url.openConnection();
String encoding = conn.getContentEncoding();
if (encoding == null) encoding = "ISO-8859-1";
BufferedReader br = n... | 1 |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (request.getParameter("edit") != null) {
try {
User cu = (User) request.getSession().getAttribute("currentuser");
UserDetails ud = cu.getUserD... | public Song(String s) {
StringTokenizer tokenizer = new StringTokenizer(s, ";");
free = false;
title = tokenizer.nextToken();
artist = tokenizer.nextToken();
location = tokenizer.nextToken();
rating = Integer.parseInt(tokenizer.nextToken());
overplay = Integer... | 1 |
public static String getHashedPassword(String password) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(password.getBytes());
BigInteger hashedInt = new BigInteger(1, digest.digest());
return String.format("%1$032X", hashedInt);
... | @Digester(forField = "password")
public static String encriptPassword(String passwd) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(passwd.getBytes());
BigInteger hash = new BigInteger(1, md.digest());
return hash.toString(16);
... | 1 |
private void extractZipFile(String filename, JTextPane progressText) throws IOException {
String destinationname = "";
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(filename));
... | public int run(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Download dir local");
return 1;
}
OutputStream out = new FileOutputStream(args[1]);
Path srcDir = new Path(args[0]);
Configuration conf = new Configuration();
... | 1 |
public static void copyFile(File sourceFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel(... | @SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("usage: " + EvaluatorHelper.class.getName() + " <output> <data set file>");
System.exit(1);
}
Helper helper = Helper.getHelper(args[... | 1 |
private boolean authenticate(Module module) throws Exception {
SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
rand.setSeed(System.currentTimeMillis());
byte[] challenge = new byte[16];
rand.nextBytes(challenge);
String b64 = Util.base64(challenge);
Util.wri... | @Digester(forField = "password")
public static String encriptPassword(String passwd) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(passwd.getBytes());
BigInteger hash = new BigInteger(1, md.digest());
return hash.toString(16);
... | 1 |
public static void copyFile(File source, File target) throws IOException {
FileChannel in = (new FileInputStream(source)).getChannel();
FileChannel out = (new FileOutputStream(target)).getChannel();
in.transferTo(0, source.length(), out);
in.close();
out.close();
}
| public byte[] getResponse() {
final ByteArrayInputStream bais = new ByteArrayInputStream(request);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
List<String> lines = Collections.emptyList();
try {
@SuppressWarnings("unchecked") List<String> dl = IOUtils.... | 1 |
public static String createPseudoUUID() {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(new UID().toString().getBytes());
try {
String localHost = InetAddress.getLocalHost().toString();
messageDi... | private void getRandomGUID(boolean secure) {
MessageDigest md5 = null;
StringBuffer sbValueBeforeMD5 = new StringBuffer();
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
System.out.println("Error: " + e);
}
... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.