id int32 0 901k | id1 int32 74 23.7M | id2 int32 74 23.7M | func1 stringlengths 234 68.5k | func2 stringlengths 234 68.5k | label bool 2
classes |
|---|---|---|---|---|---|
1,900 | 19,340,061 | 16,410,666 | public String[] fetchAutocomplete(String text) {
String[] result = new String[0];
String url = NbBundle.getMessage(MrSwingDataFeed.class, "MrSwingDataFeed.autocomplete.url", text);
HttpContext context = new BasicHttpContext();
HttpGet method = new HttpGet(url);
try {
... | public void backup(File source) throws BackupException {
try {
int index = source.getAbsolutePath().lastIndexOf(".");
if (index == -1) return;
File dest = new File(source.getAbsolutePath().substring(0, index) + ".bak");
FileChannel srcChannel = new FileInputSt... | false |
1,901 | 16,116,703 | 5,869,954 | private void save() {
int[] selection = list.getSelectionIndices();
String dir = System.getProperty("user.dir");
for (int i = 0; i < selection.length; i++) {
File src = files[selection[i]];
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFil... | public static void copyFile(File sourceFile, File targetFile) throws IOException {
FileInputStream iStream = new FileInputStream(sourceFile);
FileOutputStream oStream = new FileOutputStream(targetFile);
FileChannel inChannel = iStream.getChannel();
FileChannel outChannel = oStream.ge... | true |
1,902 | 9,918,989 | 14,024,978 | private byte[] hash(String data, HashAlg alg) {
try {
MessageDigest digest = MessageDigest.getInstance(alg.toString());
digest.update(data.getBytes());
byte[] hash = digest.digest();
return hash;
} catch (NoSuchAlgorithmException e) {
}
... | public static final String generate(String value) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
md.update(value.getBytes());
byte[] hash = md.digest();
StringBuffer hexString = new StringBuffer();
for (int... | true |
1,903 | 4,898,682 | 9,223,602 | public void run() {
try {
String s = (new StringBuilder()).append("fName=").append(URLEncoder.encode("???", "UTF-8")).append("&lName=").append(URLEncoder.encode("???", "UTF-8")).toString();
URL url = new URL("http://snoop.minecraft.net/");
HttpURLConnection httpurlconnect... | private File uploadToTmp() {
if (fileFileName == null) {
return null;
}
File tmpFile = dataDir.tmpFile(shortname, fileFileName);
log.debug("Uploading dwc archive file for new resource " + shortname + " to " + tmpFile.getAbsolutePath());
InputStream input = null;
... | false |
1,904 | 3,229,361 | 413,620 | public void copyFile(String source_name, String dest_name) throws IOException {
File source_file = new File(source_name);
File destination_file = new File(dest_name);
FileInputStream source = null;
FileOutputStream destination = null;
byte[] buffer;
int bytes_read;
... | 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));
... | true |
1,905 | 19,251,429 | 14,651,235 | private static void addFile(File file, ZipArchiveOutputStream zaos) throws IOException {
String filename = null;
filename = file.getName();
ZipArchiveEntry zae = new ZipArchiveEntry(filename);
zae.setSize(file.length());
zaos.putArchiveEntry(zae);
FileInputStream fis ... | public static Document getSkeleton() {
Document doc = null;
String filesep = System.getProperty("file.separator");
try {
java.net.URL url = Skeleton.class.getResource(filesep + "simplemassimeditor" + filesep + "resources" + filesep + "configskeleton.xml");
InputStream... | false |
1,906 | 3,287,282 | 21,093,039 | public void googleImageSearch(String start) {
try {
String u = "http://images.google.com/images?q=" + custom + start;
if (u.contains(" ")) {
u = u.replace(" ", "+");
}
URL url = new URL(u);
HttpURLConnection httpcon = (HttpURLConnec... | public ArrayList parseFile(File newfile) throws IOException {
String s;
String firstname;
String secondname;
String direction;
String header;
String name = null;
String[] tokens;
boolean readingHArrays = false;
boolean readingVArrays = false;
... | true |
1,907 | 5,856,886 | 3,657,883 | 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));
... | @Override
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException {
String context = request.getContextPath();
String resource = request.getRequestURI().replace(context, "");
resource = resource.replaceAll("^/\\w*/", "");
... | true |
1,908 | 10,903,521 | 13,669,409 | private synchronized void awaitResponse() throws BOSHException {
HttpEntity entity = null;
try {
HttpResponse httpResp = client.execute(post, context);
entity = httpResp.getEntity();
byte[] data = EntityUtils.toByteArray(entity);
String encoding = enti... | protected void runTest(URL pBaseURL, String pName, String pHref) throws Exception {
URL url = new URL(pBaseURL, pHref);
XSParser parser = new XSParser();
parser.setValidating(false);
InputSource isource = new InputSource(url.openStream());
isource.setSystemId(url.toString());... | false |
1,909 | 17,116,110 | 6,081,622 | public void deleteProposal(String id) throws Exception {
String tmp = "";
PreparedStatement prepStmt = null;
try {
if (id == null || id.length() == 0) throw new Exception("Invalid parameter");
con = database.getConnection();
String delProposal = "delete fr... | public String encryptStringWithKey(String to_be_encrypted, String aKey) {
String encrypted_value = "";
char xdigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getI... | false |
1,910 | 5,824,705 | 21,270,256 | public Object execute(Connection connection) throws JAXRException {
RegistryObject registryObject = connection.getRegistryService().getBusinessQueryManager().getRegistryObject(id);
if (registryObject instanceof ExtrinsicObject) {
ExtrinsicO... | public static boolean start(RootDoc root) {
Logger log = Logger.getLogger("DocletGenerator");
if (destination == null) {
try {
ruleListenerDef = IOUtils.toString(GeneratorOfXmlSchemaForConvertersDoclet.class.getResourceAsStream("/RuleListenersFragment.xsd"), "UTF-8");
... | true |
1,911 | 16,830,463 | 557,734 | @Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (log.isTraceEnabled()) {
log.trace("doGet(requestURI=" + request.getRequestURI() + ")");
}
ServletConfig sc = getServletConfig();
String ... | public void constructAssociationView() {
String className;
String methodName;
String field;
boolean foundRead = false;
boolean foundWrite = false;
boolean classWritten = false;
try {
AssocView = new BufferedWriter(new FileWriter("InfoFiles/Associat... | false |
1,912 | 1,001,152 | 2,313,678 | private void doOp(String urlString) {
URL url = null;
try {
url = new URL(urlString);
} catch (MalformedURLException e) {
e.printStackTrace();
return;
}
URLConnection conn = null;
try {
conn = url.openConnection();
... | protected boolean exists(String filename) {
try {
URL url = new URL(base, filename);
URLConnection conn = url.openConnection();
conn.connect();
conn.getInputStream().close();
return true;
} catch (IOException... | false |
1,913 | 8,990,219 | 10,345,032 | private boolean getCached(Get g) throws IOException {
boolean ret = false;
File f = getCachedFile(g);
if (f.exists()) {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(f);
os = new FileOutputStr... | private String GetStringFromURL(String URL) {
InputStream in = null;
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader = null;
String outstring = "";
try {
java.net.URL url = new java.net.URL(URL);
in = url.openStream();
... | false |
1,914 | 4,830,851 | 19,850,714 | @Override
protected void removeOrphansElements() throws DatabaseException {
this.getIdChache().clear();
final Connection connection = this.getConnection();
try {
connection.setAutoCommit(false);
PreparedStatement preparedStatement;
preparedStatement = ... | public HttpClient(String urlString, String jsonMessage) throws Exception {
this.jsonMessage = jsonMessage;
connection = (HttpURLConnection) (new URL(urlString)).openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod("POST");
... | false |
1,915 | 15,211,815 | 14,783,945 | private static boolean hasPackageInfo(URL url) {
if (url == null) return false;
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = br.readLine()) != null) {
if (line... | public static String compressFile(String fileName) throws IOException {
String newFileName = fileName + ".gz";
FileInputStream fis = new FileInputStream(fileName);
FileOutputStream fos = new FileOutputStream(newFileName);
GZIPOutputStream gzos = new GZIPOutputStream(fos);
byt... | false |
1,916 | 19,794,025 | 3,445,364 | public static int numberofLines(JApplet ja, String filename) {
int count = 0;
URL url = null;
String FileToRead;
FileToRead = "data/" + filename + ".csv";
try {
url = new URL(ja.getCodeBase(), FileToRead);
} catch (MalformedURLException e) {
Sy... | public Reader getReader() throws Exception {
if (url_base == null) {
return new FileReader(file);
} else {
URL url = new URL(url_base + file.getName());
return new InputStreamReader(url.openConnection().getInputStream());
}
}
| false |
1,917 | 14,686,855 | 21,234,510 | private void doDecrypt(boolean createOutput) throws IOException {
FileInputStream input = null;
FileOutputStream output = null;
File tempOutput = null;
try {
input = new FileInputStream(infile);
String cipherBaseFilename = basename(infile);
byte[] ... | public static void zip(String destination, String folder) {
File fdir = new File(folder);
File[] files = fdir.listFiles();
PrintWriter stdout = new PrintWriter(System.out, true);
int read = 0;
FileInputStream in;
byte[] data = new byte[1024];
try {
... | true |
1,918 | 14,456,151 | 20,717,530 | List HttpPost(URL url, List requestList) throws IOException {
List responseList = new ArrayList();
URLConnection con;
BufferedReader in;
OutputStreamWriter out;
StringBuffer req;
String line;
logInfo("HTTP POST: " + url);
con = url.openConnection();
... | public static String toMD5String(String plainText) {
if (TextUtils.isEmpty(plainText)) {
plainText = "";
}
StringBuilder text = new StringBuilder();
for (int i = plainText.length() - 1; i >= 0; i--) {
text.append(plainText.charAt(i));
}
plainTe... | false |
1,919 | 20,508,692 | 411,631 | private void gzip(FileHolder fileHolder) {
byte[] buffer = new byte[BUFFER_SIZE];
int bytes_read;
if (fileHolder.selectedFileList.size() == 0) {
return;
}
File destFile = new File(fileHolder.destFiles[0]);
try {
OutputStream outStream = new Fil... | 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.... | true |
1,920 | 10,171,842 | 3,459,107 | public String upload() throws IOException {
int idx = docIndex.incrementAndGet();
String tmpName = "namefinder/doc_" + idx + "__" + fileFileName;
File tmpFile = tmpFile(tmpName);
if (tmpFile.exists()) {
org.apache.commons.io.FileUtils.deleteQuietly(tmpFile);
}
... | private static boolean hardCopy(File sourceFile, File destinationFile, StringBuffer errorLog) {
boolean result = true;
try {
notifyCopyStart(destinationFile);
destinationFile.getParentFile().mkdirs();
byte[] buffer = new byte[4096];
int len = 0;
... | true |
1,921 | 19,130,322 | 1,902,197 | private String sha1(String s) {
String encrypt = s;
try {
MessageDigest sha = MessageDigest.getInstance("SHA-1");
sha.update(s.getBytes());
byte[] digest = sha.digest();
final StringBuffer buffer = new StringBuffer();
for (int i = 0; i < di... | @Override
protected ResourceHandler doGet(final URI resourceUri) throws ResourceNotFoundException, ResourceException {
if (resourceUri.getHost() == null) {
throw new IllegalStateException(InternalBundleHelper.StoreMessageBundle.getMessage("store.uri.http.illegal", resourceUri.toString()));
... | false |
1,922 | 1,458,628 | 22,652,369 | 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 AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = null;
if (useragent != null) {
URLConnection myCon = url.openConnection();
myCon.setUseCaches(false);
myCon.setDoInput(true);
... | false |
1,923 | 21,575,638 | 588,571 | protected void writeGZippedBytes(byte array[], TupleOutput out) {
if (array == null || array.length == 0) {
out.writeBoolean(false);
writeBytes(array, out);
return;
}
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(array.length);
... | public static void main(String[] args) throws Exception {
String uri = args[0];
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), conf);
InputStream in = null;
try {
in = fs.open(new Path(uri));
IOUtils.copyBytes... | true |
1,924 | 285,947 | 6,867,571 | public void process(String dir) {
String[] list = new File(dir).list();
if (list == null) return;
int n = list.length;
long[] bubblesort = new long[list.length + 1];
if (!statustext) {
IJ.log("Current Directory is: " + dir);
IJ.log(" ");
IJ... | public void run() {
synchronized (stateLock) {
if (started) {
return;
} else {
started = true;
running = true;
}
}
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
BufferedRead... | false |
1,925 | 12,800,568 | 19,627,256 | public void exportFile() {
String expfolder = PropertyHandler.getInstance().getProperty(PropertyHandler.KINDLE_EXPORT_FOLDER_KEY);
File out = new File(expfolder + File.separator + previewInfo.getTitle() + ".prc");
File f = new File(absPath);
try {
FileOutputStream fout = ... | public void compile(Project project) throws ProjectCompilerException {
List<Resource> resources = project.getModel().getResource();
for (Resource resource : resources) {
try {
IOUtils.copy(srcDir.getRelative(resource.getLocation()).getInputStream(), outDir.getRelative(res... | true |
1,926 | 4,562,924 | 22,442,269 | public static void readTestData(String getDkpUrl) throws Exception {
final URL url = new URL(getDkpUrl);
final InputStream is = url.openStream();
try {
final LineNumberReader rd = new LineNumberReader(new BufferedReader(new InputStreamReader(is)));
String line = rd.re... | public static void checkAndUpdateGameData() {
new ErrThread() {
@Override
public void handledRun() throws Throwable {
try {
URL url = new URL(ONLINE_CLIENT_DATA + "gamedata.xml");
BufferedReader br = new BufferedReader(new Inpu... | true |
1,927 | 18,781,063 | 20,508,693 | private void createGraphicalViewer(Composite parent) {
viewer = new ScrollingGraphicalViewer();
viewer.createControl(parent);
viewer.getControl().setBackground(parent.getBackground());
viewer.setRootEditPart(new ScalableFreeformRootEditPart());
viewer.setKeyHandler(new Graphi... | private void zip(FileHolder fileHolder, int zipCompressionLevel) {
byte[] buffer = new byte[BUFFER_SIZE];
int bytes_read;
if (fileHolder.selectedFileList.size() == 0) {
return;
}
File zipDestFile = new File(fileHolder.destFiles[0]);
try {
ZipOu... | false |
1,928 | 11,075,647 | 7,793,684 | @Test
public void testWriteModel() {
Model model = new Model();
model.setName("MY_MODEL1");
Stereotype st1 = new Stereotype();
st1.setName("Pirulito1");
PackageObject p1 = new PackageObject("p1");
ClassType type1 = new ClassType("Class1");
type1.setStereot... | private String createCSVFile(String fileName) throws FileNotFoundException, IOException {
String csvFile = fileName + ".csv";
BufferedReader buf = new BufferedReader(new FileReader(fileName));
BufferedWriter out = new BufferedWriter(new FileWriter(csvFile));
String line;
whil... | true |
1,929 | 4,259,286 | 17,857,284 | protected List webservice(URL url, List locations, boolean followRedirect) throws GeoServiceException {
long start = System.currentTimeMillis();
int rowCount = 0, hitCount = 0;
try {
HttpURLConnection con;
try {
con = (HttpURLConnection) url.openConnec... | public static void copyFile(File source, File destination) throws IOException {
FileChannel srcChannel = new FileInputStream(source).getChannel();
FileChannel dstChannel = new FileOutputStream(destination).getChannel();
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
srcCh... | false |
1,930 | 20,112,083 | 14,429,171 | @Override
public void connect() throws IOException {
URL url = getLocator().getURL();
if (url.getProtocol().equals("file")) {
final String newUrlStr = URLUtils.createAbsoluteFileUrl(url.toExternalForm());
if (newUrlStr != null) {
if (!newUrlStr.toString().... | public void salva(UploadedFile imagem, Usuario usuario) {
File destino;
if (usuario.getId() == null) {
destino = new File(pastaImagens, usuario.hashCode() + ".jpg");
} else {
destino = new File(pastaImagens, usuario.getId() + ".jpg");
}
try {
... | false |
1,931 | 15,760,850 | 23,537,682 | public static void main(String[] args) {
File container = new File(ArchiveFeature.class.getProtectionDomain().getCodeSource().getLocation().toURI());
if (container == null) {
throw new RuntimeException("this use-case isn't being invoked from the executable jar");
}
JarFil... | public static byte[] readResource(Class owningClass, String resourceName) {
final URL url = getResourceUrl(owningClass, resourceName);
if (null == url) {
throw new MissingResourceException(owningClass.toString() + " key '" + resourceName + "'", owningClass.toString(), resourceName);
... | true |
1,932 | 17,530,413 | 12,229,175 | protected void serveStaticContent(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException {
InputStream is = servletConfig.getServletContext().getResourceAsStream(pathInfo);
if (is == null) {
throw new ServletException("Static resource " + pathI... | public static void fileCopy(File sourceFile, File destFile) throws IOException {
FileChannel source = null;
FileChannel destination = null;
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(sourceFile);
fos = new ... | true |
1,933 | 8,139,665 | 9,059,012 | public ActionResponse executeAction(ActionRequest request) throws Exception {
BufferedReader in = null;
try {
CurrencyEntityManager em = new CurrencyEntityManager();
String id = (String) request.getProperty("ID");
CurrencyMonitor cm = getCurrencyMonitor(em, Long.v... | public static InputStream downloadStream(URL url) {
InputStream inputStream = null;
try {
URLConnection urlConnection = url.openConnection();
if (urlConnection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnect... | false |
1,934 | 4,697,213 | 23,403,205 | protected void downloadJar(URL downloadURL, File jarFile, IProgressListener pl) {
BufferedOutputStream out = null;
InputStream in = null;
URLConnection urlConnection = null;
try {
urlConnection = downloadURL.openConnection();
out = new BufferedOutputStream(new... | public void copyFile(File sourceFile, String toDir, boolean create, boolean overwrite) throws FileNotFoundException, IOException {
FileInputStream source = null;
FileOutputStream destination = null;
byte[] buffer;
int bytes_read;
File toFile = new File(toDir);
if (cre... | false |
1,935 | 18,042,543 | 4,645,054 | public void writeTo(OutputStream out) throws IOException, MessagingException {
InputStream in = getInputStream();
Base64OutputStream base64Out = new Base64OutputStream(out);
IOUtils.copy(in, base64Out);
base64Out.close();
mFile.delete();
}
| public ActualTask(TEditor editor, TIGDataBase dataBase, String directoryPath, Vector images) {
int i;
lengthOfTask = images.size();
Element dataBaseXML = new Element("dataBase");
for (i = 0; ((i < images.size()) && !stop && !cancel); i++) {
Vector ... | true |
1,936 | 24,485 | 16,435,641 | static String fetchURLComposeExternPackageList(String urlpath, String pkglisturlpath) {
String link = pkglisturlpath + "package-list";
try {
boolean relative = isRelativePath(urlpath);
readPackageList((new URL(link)).openStream(), urlpath, relative);
} catch (Malforme... | @SuppressWarnings("unchecked")
public static <T> List<T> getServices(String service) {
String serviceUri = "META-INF/services/" + service;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Enumeration<URL> urls = loader.getResources(serviceUri);
... | false |
1,937 | 19,205,402 | 14,432,775 | public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputResource.getInputStream()));
File targetDirectoryAsFile = new File(targetDirectory);
if (!targetDirectoryAsFile.exists... | static void copyFile(File in, File outDir, String outFileName) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
outDir.mkdirs();
File outFile = new File(outDir, outFileName);
FileChannel outChannel = new FileOutputStream(outFile).getChannel();
... | true |
1,938 | 21,101,965 | 5,017,376 | public String genPass() {
String salto = "Z1mX502qLt2JTcW9MTDTGBBw8VBQQmY2";
String clave = (int) (Math.random() * 10) + "" + (int) (Math.random() * 10) + "" + (int) (Math.random() * 10) + "" + (int) (Math.random() * 10) + "" + (int) (Math.random() * 10) + "" + (int) (Math.random() * 10) + "" + (int... | public static String md5(String str) {
StringBuffer buf = new StringBuffer();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] data = new byte[32];
md.update(str.getBytes(md5Encoding), 0, str.length());
data = md.digest();
... | true |
1,939 | 5,189,131 | 8,693,826 | public void service(Request req, Response resp) {
PrintStream out = null;
try {
out = resp.getPrintStream(8192);
String env = req.getParameter("env");
String regex = req.getParameter("regex");
String deep = req.getParameter("deep");
String ... | private String readJsonString() {
StringBuilder builder = new StringBuilder();
HttpClient client = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(SERVER_URL);
try {
HttpResponse response = client.execute(httpGet);
StatusLine statusLine = response.getSt... | false |
1,940 | 21,919,199 | 10,846,725 | private Datastream addManagedDatastreamVersion(Entry entry) throws StreamIOException, ObjectIntegrityException {
Datastream ds = new DatastreamManagedContent();
setDSCommonProperties(ds, entry);
ds.DSLocationType = "INTERNAL_ID";
ds.DSMIME = getDSMimeType(entry);
IRI contentL... | private DataFileType[] getDataFiles(Collection<ContentToSend> contentsToSend) {
DataFileType[] files = new DataFileType[contentsToSend.size()];
int fileIndex = 0;
for (ContentToSend contentToSend : contentsToSend) {
DataFileType dataFile = DataFileType.Factory... | true |
1,941 | 15,917,727 | 5,851,660 | public static synchronized String hash(String data) {
if (digest == null) {
try {
digest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException nsae) {
nsae.printStackTrace();
}
}
try {
digest.up... | public static String genetateSHA256(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(password.getBytes("UTF-8"));
byte[] passWd = md.digest();
String hex = toHex(passWd);
return... | true |
1,942 | 4,392,337 | 7,275,980 | @Override
public void execute(Client client, TaskProperties properties, TaskLog taskLog) throws SearchLibException {
String url = properties.getValue(propUrl);
URI uri;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
throw new SearchLibException... | public static void main(String[] args) throws IOException {
PostParameter a1 = new PostParameter("v", Utils.encode("1.0"));
PostParameter a2 = new PostParameter("api_key", Utils.encode(RenRenConstant.apiKey));
PostParameter a3 = new PostParameter("method", Utils.encode("notifications.send"))... | false |
1,943 | 9,100,840 | 8,688,357 | public static String encodeMD5(String value) {
String result = "";
try {
MessageDigest md = MessageDigest.getInstance("MD5");
BASE64Encoder encoder = new BASE64Encoder();
md.update(value.getBytes());
byte[] raw = md.digest();
result = encod... | public void runDynusT() {
final String[] exeFiles = new String[] { "DynusT.exe", "DLL_ramp.dll", "Ramp_Meter_Fixed_CDLL.dll", "Ramp_Meter_Feedback_CDLL.dll", "Ramp_Meter_Feedback_FDLL.dll", "libifcoremd.dll", "libmmd.dll", "Ramp_Meter_Fixed_FDLL.dll", "libiomp5md.dll" };
final String[] modelFiles = ... | false |
1,944 | 857,860 | 2,628,771 | public void delUser(User user) throws SQLException, IOException, ClassNotFoundException {
String dbUserID;
String stockSymbol;
Statement stmt = con.createStatement();
try {
con.setAutoCommit(false);
dbUserID = user.getUserID();
if (getUser(dbUserID... | private void initialize(Resource location) {
if (_log.isDebugEnabled()) _log.debug("loading messages from location: " + location);
String descriptorName = location.getName();
int dotx = descriptorName.lastIndexOf('.');
String baseName = descriptorName.substring(0, dotx);
Stri... | false |
1,945 | 12,415,477 | 21,495,755 | public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String limitsSet = "";
String synstatus = SystemFilesLoader.getInstance().getNewgenlibProperties().getProperty("SYNDETICS", "OFF");
String synncod... | protected Object doExecute() throws Exception {
if (args.size() == 1 && "-".equals(args.get(0))) {
log.info("Printing STDIN");
cat(new BufferedReader(io.in), io);
} else {
for (String filename : args) {
BufferedReader reader;
try {
... | false |
1,946 | 7,034,031 | 814,473 | private void copyFile(File sourceFile, File destFile) throws IOException {
if (log.isDebugEnabled()) {
log.debug("CopyFile : Source[" + sourceFile.getAbsolutePath() + "] Dest[" + destFile.getAbsolutePath() + "]");
}
if (!destFile.exists()) {
destFile.createNewFile();
... | 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... | true |
1,947 | 744,014 | 12,044,336 | static void copy(String src, String dest) throws IOException {
File ifp = new File(src);
File ofp = new File(dest);
if (ifp.exists() == false) {
throw new IOException("file '" + src + "' does not exist");
}
FileInputStream fis = new FileInputStream(ifp);
F... | @SuppressWarnings("unchecked")
private void appendAttachments(final Part part) throws MessagingException, IOException {
if (part.isMimeType("message/*")) {
JcrMessage jcrMessage = new JcrMessage();
Message attachedMessage = null;
if (part.getContent() instanceof Messa... | true |
1,948 | 6,877,678 | 20,336,463 | public static void exportGestureSet(List<GestureSet> sets, File file) {
try {
FileOutputStream outputStream = new FileOutputStream(file);
IOUtils.copy(exportGestureSetsAsStream(sets), outputStream);
outputStream.close();
} catch (FileNotFoundException e) {
... | private static void prepare() {
System.err.println("PREPARING-----------------------------------------");
deleteHome();
InputStream configStream = null;
FileOutputStream tempStream = null;
try {
configStream = AllTests.class.getClassLoader().getResourceAsStream("n... | true |
1,949 | 20,691,789 | 11,541,529 | public static void copyFile(File inputFile, File outputFile) throws IOException {
FileChannel inChannel = null;
FileChannel outChannel = null;
try {
inChannel = new FileInputStream(inputFile).getChannel();
outChannel = new FileOutputStream(outputFile).getChannel();
... | private void initFiles() throws IOException {
if (!tempDir.exists()) {
if (!tempDir.mkdir()) throw new IOException("Temp dir '' can not be created");
}
File tmp = new File(tempDir, TORRENT_FILENAME);
if (!tmp.exists()) {
FileChannel in = new FileInputStream(to... | true |
1,950 | 22,135,200 | 9,913,454 | public void testCodingCompletedFromFile() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
HttpParams params = new BasicHttpParams();
SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params... | private void createScript(File scriptsLocation, String relativePath, String scriptContent) {
Writer fileWriter = null;
try {
File scriptFile = new File(scriptsLocation.getAbsolutePath() + "/" + relativePath);
scriptFile.getParentFile().mkdirs();
fileWriter = new F... | true |
1,951 | 16,166,059 | 14,555,892 | public void transform(File inputMatrixFile, MatrixIO.Format inputFormat, File outputMatrixFile) throws IOException {
FileChannel original = new FileInputStream(inputMatrixFile).getChannel();
FileChannel copy = new FileOutputStream(outputMatrixFile).getChannel();
copy.transferFrom(original, 0... | public String getText() throws IOException {
InputStreamReader r = new InputStreamReader(getInputStream(), encoding);
StringWriter w = new StringWriter(256 * 128);
try {
IOUtils.copy(r, w);
} finally {
IOUtils.closeQuietly(w);
IOUtils.closeQuietly(... | true |
1,952 | 3,662,475 | 7,300,247 | public static String getHtml(DefaultHttpClient httpclient, String url, String encode) throws IOException {
InputStream input = null;
HttpGet get = new HttpGet(url);
HttpResponse res = httpclient.execute(get);
StatusLine status = res.getStatusLine();
if (status.getStatusCode()... | public void moveMessage(DBMimeMessage oSrcMsg) throws MessagingException {
if (DebugFile.trace) {
DebugFile.writeln("Begin DBFolder.moveMessage()");
DebugFile.incIdent();
}
JDCConnection oConn = null;
PreparedStatement oStmt = null;
ResultSet oRSet = n... | false |
1,953 | 20,081,740 | 14,254,575 | public static void main(String[] args) throws Exception {
if (args.length < 3) {
usage(System.out);
System.exit(1);
}
final File tmpFile = File.createTempFile("sej", null);
tmpFile.deleteOnExit();
final FileOutputStream destination = new FileOutputStre... | private byte[] _generate() throws NoSuchAlgorithmException {
if (host == null) {
try {
seed = InetAddress.getLocalHost().toString();
} catch (UnknownHostException e) {
seed = "localhost/127.0.0.1";
} catch (SecurityException e) {
... | false |
1,954 | 15,405,846 | 3,905,626 | public DataSet guessAtUnknowns(String filename) {
TasselFileType guess = TasselFileType.Sequence;
DataSet tds = null;
try {
BufferedReader br = null;
if (filename.startsWith("http")) {
URL url = new URL(filename);
br = new BufferedReade... | public String getScript(String script, String params) {
params = params.replaceFirst("&", "?");
StringBuffer document = new StringBuffer();
try {
URL url = new URL(script + params);
URLConnection conn = url.openConnection();
BufferedReader reader = new Buf... | true |
1,955 | 11,032,545 | 2,489,333 | @Test
public void testCopyOverSize() throws IOException {
final InputStream in = new ByteArrayInputStream(TEST_DATA);
final ByteArrayOutputStream out = new ByteArrayOutputStream(TEST_DATA.length);
final int cpySize = ExtraIOUtils.copy(in, out, TEST_DATA.length + Long.SIZE);
asser... | @Override
public String encodePassword(final String password, final Object salt) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.reset();
digest.update(salt.toString().getBytes());
byte[] passwordHash = digest.digest(password.getByt... | false |
1,956 | 23,677,120 | 14,429,171 | public static void unzip1(File zipfile, File outputdir) throws IOException {
//Buffer for copying the files out of the zip input stream
byte[] buffer = new byte[1024];
//Create parent output directory if it doesn't exist
if(!outputdir.exists()) {
outputdir.mkdirs();
}
//Create the zip input st... | public void salva(UploadedFile imagem, Usuario usuario) {
File destino;
if (usuario.getId() == null) {
destino = new File(pastaImagens, usuario.hashCode() + ".jpg");
} else {
destino = new File(pastaImagens, usuario.getId() + ".jpg");
}
try {
... | false |
1,957 | 8,361,377 | 5,832,949 | protected String decrypt(final String data, final String key) throws CryptographicFailureException {
Validate.notNull(data, "Provided data cannot be null.");
Validate.notNull(key, "Provided key name cannot be null.");
final PrivateKey pk = getPrivateKey(key);
if (pk == null) {
... | private void getImage(String filename) throws MalformedURLException, IOException, SAXException, FileNotFoundException {
String url = Constants.STRATEGICDOMINATION_URL + "/images/gameimages/" + filename;
WebRequest req = new GetMethodWebRequest(url);
WebResponse response = wc.getResponse(req)... | true |
1,958 | 5,808,067 | 266,990 | @Override
public void action(String msg, String uri, Gateway gateway) throws Exception {
String city = "成都";
if (msg.indexOf("#") != -1) {
city = msg.substring(msg.indexOf("#") + 1);
}
String url = "http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx/getWeather... | 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(... | false |
1,959 | 15,535,344 | 22,247,688 | public void testDoubleNaN() {
double value = 0;
boolean wasEqual = false;
String message = "DB operation completed";
String ddl1 = "DROP TABLE t1 IF EXISTS;" + "CREATE TABLE t1 ( d DECIMAL, f DOUBLE, l BIGINT, i INTEGER, s SMALLINT, t TINYINT, " + "dt DATE DEFAULT CURRENT_DATE, ti TI... | public void testPreparedStatementRollback1() throws Exception {
Connection localCon = getConnection();
Statement stmt = localCon.createStatement();
stmt.execute("CREATE TABLE #psr1 (data BIT)");
localCon.setAutoCommit(false);
PreparedStatement pstmt = localCon.prepareStatemen... | true |
1,960 | 9,096,612 | 20,474,021 | public void include(String href) throws ProteuException {
try {
if (href.toLowerCase().startsWith("http://")) {
java.net.URLConnection urlConn = (new java.net.URL(href)).openConnection();
Download.sendInputStream(this, urlConn.getInputStream());
} else... | public static byte[] createAuthenticator(ByteBuffer data, String secret) {
assert data.isDirect() == false : "must not a direct ByteBuffer";
int pos = data.position();
if (pos < RadiusPacket.MIN_PACKET_LENGTH) {
System.err.println("packet too small");
return null;
... | false |
1,961 | 15,228,322 | 2,498,760 | public void createIndex(File indexDir) throws SearchLibException, IOException {
if (!indexDir.mkdir()) throw new SearchLibException("directory creation failed (" + indexDir + ")");
InputStream is = null;
FileWriter target = null;
for (String resource : resources) {
String... | public Main(String[] args) {
boolean encrypt = false;
if (args[0].compareTo("-e") == 0) {
encrypt = true;
} else if (args[0].compareTo("-d") == 0) {
encrypt = false;
} else {
System.out.println("first argument is invalid");
System.exit(... | true |
1,962 | 19,693,671 | 11,986,777 | public static String hash(String password) {
try {
MessageDigest digest = MessageDigest.getInstance(digestAlgorithm);
digest.update(password.getBytes(charset));
byte[] rawHash = digest.digest();
return new String(Hex.encodeHex(rawHash));
} catch (Excep... | private List<Token> generateTokens(int tokenCount) throws XSServiceException {
final List<Token> tokens = new ArrayList<Token>(tokenCount);
final Random r = new Random();
String t = Long.toString(new Date().getTime()) + Integer.toString(r.nextInt());
final MessageDigest m;
tr... | true |
1,963 | 17,217,414 | 3,024,978 | public void addEntry(InputStream jis, JarEntry entry) throws IOException, URISyntaxException {
File target = new File(this.target.getPath() + entry.getName()).getAbsoluteFile();
if (!target.exists()) {
target.createNewFile();
}
if ((new File(this.source.toURI())).isDirect... | @Test
public void testCopy_inputStreamToWriter_nullIn() throws Exception {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
OutputStream out = new YellOnFlushAndCloseOutputStreamTest(baout, true, true);
Writer writer = new OutputStreamWriter(baout, "US-ASCII");
try {
... | true |
1,964 | 22,807,014 | 22,625,096 | @Test
public void test() throws JDOMException, IOException {
InputStream is = this.getClass().getResourceAsStream("putRegularVehicle.xml");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
IOUtils.copy(is, byteArrayOutputStream);
TrafficModelDefinition d... | public void run() {
long starttime = (new Date()).getTime();
Matcher m = Pattern.compile("(\\S+);(\\d+)").matcher(Destination);
boolean completed = false;
if (OutFile.length() > IncommingProcessor.MaxPayload) {
logger.warn("Payload is too large!");
close();
... | true |
1,965 | 15,821,341 | 11,370,967 | public void update() {
try {
String passwordMD5 = new String();
if (this.password != null && this.password.length() > 0) {
MessageDigest md = MessageDigest.getInstance("md5");
md.update(this.password.getBytes());
byte[] digest = md.dige... | public void copyFile(File in, File out) throws Exception {
FileChannel ic = new FileInputStream(in).getChannel();
FileChannel oc = new FileOutputStream(out).getChannel();
ic.transferTo(0, ic.size(), oc);
ic.close();
oc.close();
}
| false |
1,966 | 23,147,989 | 17,477,951 | public boolean copy(String file, String path) {
try {
File file_in = new File(file);
String tmp1, tmp2;
tmp1 = file;
tmp2 = path;
while (tmp2.contains("\\")) {
tmp2 = tmp2.substring(tmp2.indexOf("\\") + 1);
tmp1 = tm... | public static void copy(String inputFile, String outputFile) throws Exception {
try {
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
... | true |
1,967 | 22,306,604 | 22,275,470 | public static void upLoadFile(File sourceFile, File targetFile) throws IOException {
FileChannel inChannel = null;
FileChannel outChannel = null;
try {
inChannel = new FileInputStream(sourceFile).getChannel();
outChannel = new FileOutputStream(targetFile).getChannel()... | public static boolean insert(final Funcionario objFuncionario) {
int result = 0;
final Connection c = DBConnection.getConnection();
PreparedStatement pst = null;
if (c == null) {
return false;
}
try {
c.setAutoCommit(false);
final S... | false |
1,968 | 4,147,982 | 14,710,734 | public static void fixEol(File fin) throws IOException {
File fout = File.createTempFile(fin.getName(), ".fixEol", fin.getParentFile());
FileChannel in = new FileInputStream(fin).getChannel();
if (0 != in.size()) {
FileChannel out = new FileOutputStream(fout).getChannel();
... | public static boolean writeFile(HttpServletResponse resp, File reqFile) {
boolean retVal = false;
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(reqFile));
IOUtils.copy(in, resp.getOutputStream());
logger.debug("File successf... | true |
1,969 | 16,294,877 | 8,559,503 | public static void copierFichier(URL url, File destination) throws CopieException, IOException {
if (destination.exists()) {
throw new CopieException("ERREUR : Copie du fichier '" + url.getPath() + "' vers '" + destination.getPath() + "' impossible!\n" + "CAUSE : Le fichier destination existe d... | public void login(String username, String key) {
if (isLogged()) {
return;
}
if (null == this.username || null == this.key) {
this.username = username;
this.key = key;
}
final ProgressHandle handle = ProgressHandleFactory.createHandle("Logi... | false |
1,970 | 18,432,299 | 12,127,276 | private String addEqError(EquivalencyException e, int namespaceId) throws SQLException {
List l = Arrays.asList(e.getListOfEqErrors());
int size = l.size();
String sql = getClassifyDAO().getStatement(TABLE_KEY, "ADD_CLASSIFY_EQ_ERROR");
PreparedStatement ps = null;
conn.setAu... | public void testGetResource_FileOutsideOfClasspath() throws Exception {
File temp = File.createTempFile("dozerfiletest", ".txt");
temp.deleteOnExit();
String resourceName = "file:" + temp.getAbsolutePath();
URL url = loader.getResource(resourceName);
assertNotNull("URL should... | false |
1,971 | 2,326,683 | 1,889,366 | public static void encrypt(File plain, File symKey, File ciphered, String algorithm) throws IOException, ClassNotFoundException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {
Key key = null;
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(... | public String hash(String password) {
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException ex) {
log.info("No sha-256 available");
try {
digest = MessageDigest.getInstance("SHA-... | false |
1,972 | 14,085,200 | 20,334,946 | private static String getRegistrationClasses() {
CentralRegistrationClass c = new CentralRegistrationClass();
String name = c.getClass().getCanonicalName().replace('.', '/').concat(".class");
try {
Enumeration<URL> urlEnum = c.getClass().getClassLoader().getResources("META-INF/MA... | public static String doPost(String http_url, String post_data) {
if (post_data == null) {
post_data = "";
}
try {
URLConnection conn = new URL(http_url).openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCac... | false |
1,973 | 1,741,919 | 2,807,114 | public static String hash(String text) throws Exception {
StringBuffer hexString;
MessageDigest mdAlgorithm = MessageDigest.getInstance("MD5");
mdAlgorithm.update(text.getBytes());
byte[] digest = mdAlgorithm.digest();
hexString = new StringBuffer();
for (int i = 0; i... | public Controller(String m_hostname, String team, boolean m_shouldexit) throws InternalException {
m_received_messages = new ConcurrentLinkedQueue<ReceivedMessage>();
m_fragmsgs = new ArrayList<String>();
m_customizedtaunts = new HashMap<Integer, String>();
m_nethandler = new Caching... | false |
1,974 | 7,926,874 | 430,971 | public static void main(String arg[]) {
try {
String readFile = arg[0];
String writeFile = arg[1];
java.io.FileInputStream ss = new java.io.FileInputStream(readFile);
ManagedMemoryDataSource ms = new ManagedMemoryDataSource(ss, 1024 * 1024, "foo/data", true);
... | public static void copyFile(File destFile, File src) throws IOException {
File destDir = destFile.getParentFile();
File tempFile = new File(destFile + "_tmp");
destDir.mkdirs();
InputStream is = new FileInputStream(src);
try {
FileOutputStream os = new FileOutputS... | true |
1,975 | 2,031,752 | 7,468,813 | public String readFile(String filename) throws UnsupportedEncodingException, FileNotFoundException, IOException {
File f = new File(baseDir);
f = new File(f, filename);
StringWriter w = new StringWriter();
Reader fr = new InputStreamReader(new FileInputStream(f), "UTF-8");
IO... | public static String doPostWithBasicAuthentication(URL url, String username, String password, String parameters, Map<String, String> headers) throws IOException {
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setDoInput(true);
con... | false |
1,976 | 9,819,955 | 3,024,984 | @Override
public void write(OutputStream output) throws IOException, WebApplicationException {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final GZIPOutputStream gzipOs = new GZIPOutputStream(baos);
IOUtils.copy(is, gzipOs);
baos.close();
gzipOs.close(... | @Test
public void testCopy_readerToOutputStream() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStreamTest(in);
Reader reader = new InputStreamReader(in, "US-ASCII");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
... | true |
1,977 | 5,390,079 | 16,250,771 | private Map getBlackHoleData() throws Exception {
File dataFile = new File(Kit.getDataDir() + BLACK_HOLE);
if (dataFile.exists() && daysOld(dataFile) < 1) {
return getStoredData(dataFile);
}
InputStream stream = null;
try {
String bh_url = "http://www.... | public static String genDigest(String info) {
MessageDigest alga;
byte[] digesta = null;
try {
alga = MessageDigest.getInstance("SHA-1");
alga.update(info.getBytes());
digesta = alga.digest();
} catch (NoSuchAlgorithmException e) {
e.pr... | false |
1,978 | 21,605,296 | 9,830,264 | public void transport(File file) throws TransportException {
FTPClient client = new FTPClient();
try {
client.connect(getOption("host"));
client.login(getOption("username"), getOption("password"));
client.changeWorkingDirectory(getOption("remotePath"));
... | public static void main(final String[] args) {
final Runnable startDerby = new Runnable() {
public void run() {
try {
final NetworkServerControl control = new NetworkServerControl(InetAddress.getByName("localhost"), 1527);
control.start(ne... | false |
1,979 | 22,420,606 | 11,143,530 | public void download() {
try {
URL url = new URL(srcURL + src);
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
FileOutputStream fos = new FileOutputStream(de... | private String readUrl(String feature) {
StringBuffer content = new StringBuffer();
try {
URL url = new URL(feature);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.connect();
BufferedReader rd = new BufferedReader(new InputStr... | false |
1,980 | 13,281,981 | 23,165,929 | private void bokActionPerformed(java.awt.event.ActionEvent evt) {
Vector vret = this.uniformtitlepanel.getEnteredValuesKeys();
String[] patlib = newgen.presentation.NewGenMain.getAppletInstance().getPatronLibraryIds();
String xmlreq = newgen.presentation.administration.AdministrationXMLGener... | private void createCanvas() {
GraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.setRootEditPart(new ScalableRootEditPart());
viewer.setEditPartFactory(new BlockEditPartFactory());
viewer.createControl(this);
viewer.setKeyHandler(new GraphicalViewerKeyHandler(vie... | false |
1,981 | 22,416,749 | 590,175 | private int getRootNodeId(DataSource dataSource) throws SQLException {
Connection conn = null;
Statement st = null;
ResultSet rs = null;
String query = null;
try {
conn = dataSource.getConnection();
st = conn.createStatement();
query = "sel... | private static KeyStore createKeyStore(final URL url, final String password) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
if (url == null) {
throw new IllegalArgumentException("Keystore url may not be null");
}
LOG.debug("Initializing ke... | false |
1,982 | 8,258,096 | 18,465,677 | private String encryptPassword(String password) throws NoSuchAlgorithmException {
StringBuffer encryptedPassword = new StringBuffer();
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.reset();
md5.update(password.getBytes());
byte digest[] = md5.digest();
for... | public void download(RequestContext ctx) throws IOException {
if (ctx.isRobot()) {
ctx.forbidden();
return;
}
long id = ctx.id();
File bean = File.INSTANCE.Get(id);
if (bean == null) {
ctx.not_found();
return;
}
... | false |
1,983 | 13,421,720 | 15,287,816 | public static String download(String address, String outputFolder) {
URL url = null;
String fileName = "";
try {
url = new URL(address);
System.err.println("Indirizzo valido!");
} catch (MalformedURLException ex) {
System.err.println("Indirizzo non... | public Vector<Question> reload() throws IOException {
Vector<Question> questions = new Vector<Question>();
InputStream is = url.openStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
shortName = br.readLine();
if (shortName != null && shortName.equal... | false |
1,984 | 5,706,224 | 17,887,703 | public void run() {
try {
File outDir = new File(outDirTextField.getText());
if (!outDir.exists()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(... | private boolean confirmAndModify(MDPRArchiveAccessor archiveAccessor) {
String candidateBackupName = archiveAccessor.getArchiveFileName() + ".old";
String backupName = createUniqueFileName(candidateBackupName);
MessageFormat format = new MessageFormat(AUTO_MOD_MESSAGE);
String messag... | true |
1,985 | 19,338,729 | 8,344,457 | public static InputStream call(String serviceUrl, Map parameters) throws IOException, RestException {
StringBuffer urlString = new StringBuffer(serviceUrl);
String query = RestClient.buildQueryString(parameters);
HttpURLConnection conn;
if ((urlString.length() + query.length() + 1) >... | private static void addFileToZip(String path, String srcFile, ZipOutputStream zip, String prefix, String suffix) throws Exception {
File folder = new File(srcFile);
if (folder.isDirectory()) {
addFolderToZip(path, srcFile, zip, prefix, suffix);
} else {
if (isFileName... | false |
1,986 | 17,398,520 | 7,396,681 | public void SendFile(File testfile) {
try {
SocketChannel sock = SocketChannel.open(new InetSocketAddress("127.0.0.1", 1234));
sock.configureBlocking(true);
while (!sock.finishConnect()) {
System.out.println("NOT connected!");
}
Sys... | public static boolean copy(File src, FileSystem dstFS, Path dst, boolean deleteSource, Configuration conf) throws IOException {
dst = checkDest(src.getName(), dstFS, dst, false);
if (src.isDirectory()) {
if (!dstFS.mkdirs(dst)) {
return false;
}
Fi... | true |
1,987 | 3,762,872 | 22,924,617 | public String getHash(String str) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.getBytes());
byte[] toChapter1Digest = md.digest();
return Keystore.hexEncode(toChapter1Digest);
} catch (Exception e) {
logger.err... | private String md5(String s) {
try {
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(s.getBytes());
byte messageDigest[] = digest.digest();
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < messag... | true |
1,988 | 5,746,377 | 2,244,282 | @Override
public JSONObject runCommand(JSONObject payload, HttpSession session) throws DefinedException {
String sessionId = session.getId();
log.debug("Login -> runCommand SID: " + sessionId);
JSONObject toReturn = new JSONObject();
boolean isOK = true;
String username =... | private InputStream loadSource(String url) throws ClientProtocolException, IOException {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(HTTP.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)");
HttpGet httpget = new HttpGet(url);
H... | false |
1,989 | 22,323,688 | 15,311,521 | public String makeLeoNounCall(String noun) {
String ret = "";
StringBuffer buf = new StringBuffer();
try {
URL url = new URL("http://dict.leo.org" + noun);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), Charset.forName("ISO8859_1")));
... | public String buscaCDA() {
Properties prop = new CargaProperties().Carga();
URL url;
BufferedReader in;
String inputLine;
String miLinea = null;
try {
url = new URL(prop.getProperty("CDA"));
in = new BufferedReader(new InputStreamReader(url.ope... | true |
1,990 | 14,776,145 | 21,204,167 | private void addPNMLFileToLibrary(File selected) {
try {
FileChannel srcChannel = new FileInputStream(selected.getAbsolutePath()).getChannel();
FileChannel dstChannel = new FileOutputStream(new File(matchingOrderXML).getParent() + "/" + selected.getName()).getChannel();
d... | private String getEncryptedPassword() {
String encrypted;
char[] pwd = password.getPassword();
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(new String(pwd).getBytes("UTF-8"));
byte[] digested = md.digest();
encrypted =... | false |
1,991 | 5,567,860 | 22,246,374 | public String getClass(EmeraldjbBean eb) throws EmeraldjbException {
Entity entity = (Entity) eb;
StringBuffer sb = new StringBuffer();
String myPackage = getPackageName(eb);
sb.append("package " + myPackage + ";\n");
sb.append("\n");
DaoValuesGenerator valgen = new D... | 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.... | true |
1,992 | 7,237,429 | 5,785,861 | public void readContents() throws IOException {
fireProgressEvent(new ProgressEvent(this, ProgressEvent.PROGRESS_START, 0.0f, "loading file"));
URLConnection conn = url.openConnection();
conn.connect();
filesize = conn.getContentLength();
logger.finest("filesize: " + filesize... | @Test
public void testEncryptDecrypt() throws IOException {
BlockCipher cipher = new SerpentEngine();
Random rnd = new Random();
byte[] key = new byte[256 / 8];
rnd.nextBytes(key);
byte[] iv = new byte[cipher.getBlockSize()];
rnd.nextBytes(iv);
byte[] data... | false |
1,993 | 418,257 | 10,177,034 | 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 synchronized BaseFont getL2BaseFont() {
if (l2baseFont == null) {
final ConfigProvider conf = ConfigProvider.getInstance();
try {
final ByteArrayOutputStream tmpBaos = new ByteArrayOutputStream();
String fontPath = conf.getNotEmptyPropert... | true |
1,994 | 6,371,592 | 9,013,668 | public void deleteUser(final List<Integer> userIds) {
try {
connection.setAutoCommit(false);
new ProcessEnvelope().executeNull(new ExecuteProcessAbstractImpl(connection, false, false, true, true) {
@Override
public void executeProcessReturnNull() thro... | public synchronized String encrypt(String plaintext) throws SystemUnavailableException {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
throw new SystemUnavailableException(e.getMessage());
}
... | false |
1,995 | 4,886,971 | 2,021,565 | private static void copyFile(String srFile, String dtFile) {
try {
File f1 = new File(srFile);
File f2 = new File(dtFile);
InputStream in = new FileInputStream(f1);
OutputStream out = new FileOutputStream(f2);
byte[] buf = new byte[1024];
... | public void mkdirs(String path) throws IOException {
GridFTP ftp = new GridFTP();
ftp.setDefaultPort(port);
System.out.println(this + ".mkdirs " + path);
try {
ftp.connect(host);
ftp.login(username, password);
int reply = ftp.getReplyCode();
... | false |
1,996 | 740,874 | 9,581,835 | 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 void main(String[] args) {
String WTKdir = null;
String sourceFile = null;
String instrFile = null;
String outFile = null;
String jadFile = null;
Manifest mnf;
if (args.length == 0) {
usage();
return;
}
int... | true |
1,997 | 3,153,908 | 19,850,714 | public boolean connentServer() {
boolean result = false;
try {
ftpClient = new FTPClient();
ftpClient.setDefaultPort(port);
ftpClient.setControlEncoding("GBK");
strOut = strOut + "Connecting to host " + host + "\r\n";
ftpClient.connect(host... | public HttpClient(String urlString, String jsonMessage) throws Exception {
this.jsonMessage = jsonMessage;
connection = (HttpURLConnection) (new URL(urlString)).openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod("POST");
... | false |
1,998 | 23,241,194 | 16,116,703 | private void publishZip(LWMap map) {
try {
if (map.getFile() == null) {
VueUtil.alert(VueResources.getString("dialog.mapsave.message"), VueResources.getString("dialog.mapsave.title"));
return;
}
File savedCMap = PublishUtil.createZip(map, P... | private void save() {
int[] selection = list.getSelectionIndices();
String dir = System.getProperty("user.dir");
for (int i = 0; i < selection.length; i++) {
File src = files[selection[i]];
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFil... | true |
1,999 | 9,552,054 | 18,099,260 | public static void copy(String fromFileName, String toFileName) throws IOException {
File fromFile = new File(fromFileName);
File toFile = new File(toFileName);
if (!fromFile.exists()) throw new IOException("FileCopy: " + "no such source file: " + fromFileName);
if (!fromFile.isFile(... | public String[][] getProjectTreeData() {
String[][] treeData = null;
String filename = dms_home + FS + "temp" + FS + username + "projects.xml";
String urlString = dms_url + "/servlet/com.ufnasoft.dms.server.ServerGetProjects";
try {
String urldata = urlString + "?username... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.