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 |
|---|---|---|---|---|---|
4,600 | 15,854,363 | 17,415,425 | 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");
}
FileInputStream input = new FileInput... | public void overwriteTest() throws Exception {
SRBAccount srbAccount = new SRBAccount("srb1.ngs.rl.ac.uk", 5544, this.cred);
srbAccount.setDefaultStorageResource("ral-ngs1");
SRBFileSystem client = new SRBFileSystem(srbAccount);
client.setFirewallPorts(64000, 65000);
String h... | true |
4,601 | 7,436,647 | 3,861,343 | @Test
public void testFromFile() throws IOException {
File temp = File.createTempFile("fannj_", ".tmp");
temp.deleteOnExit();
IOUtils.copy(this.getClass().getResourceAsStream("xor_float.net"), new FileOutputStream(temp));
Fann fann = new Fann(temp.getPath());
assertEquals... | protected void truncate(File file) {
LogLog.debug("Compression of file: " + file.getAbsolutePath() + " started.");
if (FileUtils.isFileOlder(file, ManagementFactory.getRuntimeMXBean().getStartTime())) {
File backupRoot = new File(getBackupDir());
if (!backupRoot.exists() && !... | true |
4,602 | 6,740,469 | 7,524,607 | private void copyFile(String sourceFilename, String destDirname) throws BuildException {
log("Copying file " + sourceFilename + " to " + destDirname);
File destFile = getDestFile(sourceFilename, destDirname);
InputStream inStream = null;
OutputStream outStream = null;
try {
... | private void copyFile(String file) {
FileChannel inChannel = null;
FileChannel outChannel = null;
try {
Date dt = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd HHmmss ");
File in = new File(file);
String[] name = file.split("... | true |
4,603 | 3,253,024 | 614,390 | private static void recurseFiles(File root, File file, TarArchiveOutputStream taos, boolean absolute) throws IOException {
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File file2 : files) {
recurseFiles(root, file2, taos, absolute);
}
... | 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 |
4,604 | 6,068,118 | 10,466,758 | public byte[] exportCommunityData(String communityId) throws RepositoryException, IOException {
Community community;
try {
community = getCommunityById(communityId);
} catch (CommunityNotFoundException e1) {
throw new GroupwareRuntimeException("Community to export not... | public void handleRequestInternal(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws ServletException, IOException {
final String servetPath = httpServletRequest.getServletPath();
final String previousToken = httpServletRequest.getHeader(IF_NONE_MATCH)... | true |
4,605 | 21,931,071 | 21,374,275 | public static void writeToPetrify(TransitionSystem ts, Writer bw) throws IOException {
File temp = new File("_temp");
BufferedWriter tw = new BufferedWriter(new FileWriter(temp));
BufferedReader tr = new BufferedReader(new FileReader(temp));
HashSet<ModelGraphVertex> sources = new Ha... | private 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 (IOExce... | true |
4,606 | 21,291,602 | 1,995,571 | 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");
}
FileInputStream input = new FileInput... | protected Source resolveRepositoryURI(String path) throws TransformerException {
Source resolvedSource = null;
try {
if (path != null) {
URL url = new URL(path);
InputStream in = url.openStream();
if (in != null) {
resol... | false |
4,607 | 651,715 | 17,482,505 | 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... | public void createResource(String resourceUri, boolean publish, User user) throws IOException {
PermissionAPI perAPI = APILocator.getPermissionAPI();
Logger.debug(this.getClass(), "createResource");
resourceUri = stripMapping(resourceUri);
String hostName = getHostname(resourceUri);
... | true |
4,608 | 6,361,318 | 14,635,922 | public void run() {
date = DateUtil.addMonth(-1);
List list = bo.getDao().getHibernateTemplate().find("from MailAffixPojo where upload_time <'" + date + "' and to_number(sized) >" + size);
if (null != list && list.size() > 0) {
try {
FTPClient ftp = new FTPClient(... | public String contactService(String service, StringBuffer xmlRequest) throws Exception {
Logger.debug(UPSConnections.class, "UPS CONNECTIONS ***** Started " + service + " " + new Date().toString() + " *****");
HttpURLConnection connection;
URL url;
String response = "";
try {... | false |
4,609 | 151,885 | 557,732 | private static void main(String[] args) {
try {
File f = new File("test.txt");
if (f.exists()) {
throw new IOException(f + " already exists. I don't want to overwrite it.");
}
StraightStreamReader in;
char[] cbuf = new char[0x1000]... | public void constructFundamentalView() {
String className;
String methodName;
String field;
boolean foundRead = false;
boolean foundWrite = false;
boolean classWritten = false;
try {
FundView = new BufferedWriter(new FileWriter("InfoFiles/Fundament... | true |
4,610 | 17,662,180 | 9,913,454 | public XlsBook(String path) throws IOException {
boolean isHttp = path.startsWith("http://");
InputStream is = null;
if (isHttp) {
URL url = new URL(path);
is = url.openStream();
} else {
File file = new File(path);
is = new FileInputSt... | 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... | false |
4,611 | 19,812,348 | 6,608,439 | static ConversionMap create(String file) {
ConversionMap out = new ConversionMap();
URL url = ConversionMap.class.getResource(file);
try {
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line = in.readLine();
while (... | public static void main(String[] args) {
FTPClient client = new FTPClient();
try {
File l_file = new File("C:/temp/testLoribel.html");
String l_url = "http://www.loribel.com/index.html";
GB_HttpTools.loadUrlToFile(l_url, l_file, ENCODING.ISO_8859_1);
S... | false |
4,612 | 9,261,908 | 12,660,385 | public NamedList<Object> request(final SolrRequest request, ResponseParser processor) throws SolrServerException, IOException {
HttpMethod method = null;
InputStream is = null;
SolrParams params = request.getParams();
Collection<ContentStream> streams = requestWriter.getContentStream... | @Override
public boolean accept(File file) {
if (file.getName().equals(".svn")) {
return false;
}
final long modify = file.lastModified();
final long time = DateUtils.toDate("2012-03-21 17:43", "yyyy-MM-dd HH:mm"... | true |
4,613 | 7,902,692 | 18,390,011 | @Override
public MapInfo getMap(int mapId) {
MapInfo info = mapCache.get(mapId);
if (info != null && info.getContent() == null) {
if (info.getInfo().get("fileName") == null) {
if (mapId != lastRequestedMap) {
lastRequestedMap = mapId;
... | private String fetchURL(String url) {
StringBuilder content = new StringBuilder();
String line;
BufferedReader input = null;
try {
URL urlToFetch = new URL(url);
input = new BufferedReader(new InputStreamReader(urlToFetch.openStream()));
while ((li... | true |
4,614 | 17,253,878 | 7,306,113 | public void onUpload$btnFileUpload(UploadEvent ue) {
BufferedInputStream in = null;
BufferedOutputStream out = null;
if (ue == null) {
System.out.println("unable to upload file");
return;
} else {
System.out.println("fileUploaded()");
}
... | @Override
public void setOntology1Document(URL url1) throws IllegalArgumentException {
if (url1 == null) throw new IllegalArgumentException("Input parameter URL for ontology 1 is null.");
try {
ont1 = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(url1.openStr... | false |
4,615 | 6,644,756 | 12,214,442 | public void alterar(Cliente cliente) throws Exception {
Connection connection = criaConexao(false);
String sql = "update cliente set nome = ?, sexo = ?, cod_cidade = ? where cod_cliente = ?";
PreparedStatement stmt = null;
try {
stmt = connection.prepareStatement(sql);
... | public boolean saveTemplate(Template t) {
try {
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
String query;
ResultSet rset;
if (Integer.parseInt(executeMySQLGet("SELECT COUNT(*) FROM templates WHERE name='" + escapeCharacters(... | true |
4,616 | 7,512,156 | 4,247,524 | @Override
public void execute(String[] args) throws Exception {
Options cmdLineOptions = getCommandOptions();
try {
GnuParser parser = new GnuParser();
CommandLine commandLine = parser.parse(cmdLineOptions, TolvenPlugin.getInitArgs());
String srcRepositoryURLS... | public static String backupFile(File source) {
File backup = new File(source.getParent() + "/~" + source.getName());
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(source)));
BufferedWriter writer = new BufferedWriter(new OutputStre... | true |
4,617 | 20,265,649 | 2,362,300 | public static void setFinishedFlag(String ip, String port, String user, String dbname, String password, int flag) throws Exception {
String sql = "update flag set flag = " + flag;
Connection conn = CubridDBCenter.getConnection(ip, port, dbname, user, password);
System.out.println("====:::===... | static void test() throws SQLException {
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
conn = JdbcUtils.getConnection();
conn.setAutoCommit(false);
st = conn.createStatement();
String sql = "update user set mon... | true |
4,618 | 6,037,299 | 15,669,668 | public void copyAffix(MailAffix affix, long mailId1, long mailId2) throws Exception {
File file = new File(this.getResDir(mailId1) + affix.getAttachAlias());
if (file.exists()) {
File file2 = new File(this.getResDir(mailId2) + affix.getAttachAlias());
if (!file2.exists()) {
... | private static FileChannel getFileChannel(File file, boolean isOut, boolean append) throws OpenR66ProtocolSystemException {
FileChannel fileChannel = null;
try {
if (isOut) {
FileOutputStream fileOutputStream = new FileOutputStream(file.getPath(), append);
... | true |
4,619 | 22,131,351 | 250,596 | private IMolecule readMolecule() throws Exception {
String xpath = "";
if (index.equals("ichi")) {
xpath = URLEncoder.encode("//molecule[./identifier/basic='" + query + "']", UTF8);
} else if (index.equals("kegg")) {
xpath = URLEncoder.encode("//molecule[./@name='" + ... | 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.... | false |
4,620 | 22,287,078 | 970,639 | @Override
List<String> HttpGet(URL url) throws IOException {
List<String> responseList = new ArrayList<String>();
Logger.getInstance().logInfo("HTTP GET: " + url, null, getGatewayId());
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setConnectTimeout(20000)... | public static String unsecureHashConstantSalt(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
password = SALT3 + password;
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(password.getBytes(), 0, password.length());
password += convert... | false |
4,621 | 21,382,198 | 18,298,938 | private void initializeTree() {
InputStreamReader reader = null;
BufferedReader buffReader = null;
try {
for (int i = 0; i < ORDER.length; i++) {
int index = ORDER[i];
String indexName = index < 10 ? "0" + index : (index > 20 ? "big" : "" + index);... | public void loginOAuth() throws OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException, ClientProtocolException, IOException, IllegalStateException, SAXException, ParserConfigurationException, FactoryConfigurationError, AndroidException {
String url = getAuthentificationUR... | false |
4,622 | 6,382,798 | 11,799,025 | public String readURL(URL url) throws JasenException {
OutputStream out = new ByteArrayOutputStream();
InputStream in = null;
String html = null;
NonBlockingStreamReader reader = null;
try {
in = url.openStream();
reader = new NonBlockingStreamReader()... | @Override
public Document duplicate() {
BinaryDocument b = new BinaryDocument(this.name, this.content.getContentType());
try {
IOUtils.copy(this.getContent().getInputStream(), this.getContent().getOutputStream());
return b;
} catch (IOException e) {
th... | false |
4,623 | 18,810,216 | 6,085,930 | private void doIt() throws Throwable {
int numCachedTiles = 0;
try {
List<MapTile> backTiles = new ArrayList<MapTile>();
final LatLngRectangle bounds = new LatLngRectangle(new LatLngPoint(south, west), new LatLngPoint(north, east));
final String backMapGuid = "gst... | public void update() {
if (!updatable) {
Main.fenetre().erreur(Fenetre.OLD_VERSION);
return;
}
try {
Main.fenetre().update();
Element remoteRoot = new SAXBuilder().build(xml).getRootElement();
addPackages = new HashMap<Integer, Pack... | true |
4,624 | 20,331,164 | 23,113,417 | public int read(String name) {
status = STATUS_OK;
try {
name = name.trim().toLowerCase();
if ((name.indexOf("file:") >= 0) || (name.indexOf(":/") > 0)) {
URL url = new URL(name);
in = new BufferedInputStream(url.openStream());
} el... | public TreeNode fetchArchive(TreeNode owner, int id) throws Exception {
builder.start(owner, false);
parser.setDocumentHandler(builder);
String arg = server + "?todo=archive&db=" + db + "&document=" + document + "&id=" + id;
URL url = new URL(arg);
URLConnection con = url.ope... | false |
4,625 | 19,926,877 | 310,580 | @Override
public void createCopy(File sourceFile, File destinnationFile) throws IOException {
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();
destination = new FileOutputStream(destinnationFil... | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | true |
4,626 | 20,662,462 | 16,797,552 | @Override
public DownloadingItem download(Playlist playlist, String title, File folder, StopDownloadCondition condition, String uuid) throws IOException, StoreStateException {
boolean firstIteration = true;
Iterator<PlaylistEntry> entries = playlist.getEntries().iterator();
DownloadingIt... | public boolean restore() {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "/Android/bluebox.bak";
String backupDBPath = "/data/android.blueb... | true |
4,627 | 23,141,718 | 18,138,572 | protected URLConnection openConnection(URL url) throws IOException {
if (bundleEntry != null) return (new BundleURLConnection(url, bundleEntry));
String bidString = url.getHost();
if (bidString == null) {
throw new IOException(NLS.bind(AdaptorMsg.URL_NO_BUNDLE_ID, url.toExternalF... | public static String[] getURLListFromResource(String resourceName, String regExFilter, boolean firstNoEmptyMatched) {
String[] urlArray;
Vector<String> urlVector = new Vector<String>();
try {
ClassLoader classLoader = MqatMain.class.getClassLoader();
URLClassLoader ur... | false |
4,628 | 20,305,472 | 7,119,938 | @Override
public void run() {
try {
FileChannel out = new FileOutputStream(outputfile).getChannel();
long pos = 0;
status.setText("Slučovač: Proces Slučování spuštěn.. Prosím čekejte..");
for (int i = 1; i <= noofparts; i++) {
FileChannel i... | public void putFile(CompoundName file, FileInputStream fileInput) throws IOException {
File fullDir = new File(REMOTE_BASE_DIR.getCanonicalPath());
for (int i = 0; i < file.size() - 1; i++) fullDir = new File(fullDir, file.get(i));
fullDir.mkdirs();
File outputFile = new File(fullDir... | true |
4,629 | 19,392,393 | 13,099,597 | private void addIngredients(Recipe recipe, int id) throws Exception {
PreparedStatement pst = null;
try {
conn = getConnection();
pst = conn.prepareStatement("INSERT INTO ingredients (recipe_id, name, amount, measure_id, shop_flag) VALUES (?,?,?,?,?)");
Ingredient... | public void deleteGroup(String groupID) throws XregistryException {
try {
Connection connection = context.createConnection();
connection.setAutoCommit(false);
try {
PreparedStatement statement1 = connection.prepareStatement(DELETE_GROUP_SQL_MAIN);
... | true |
4,630 | 8,267,306 | 14,770,723 | public void testWriteThreadsNoCompression() throws Exception {
Bootstrap bootstrap = new Bootstrap();
bootstrap.loadProfiles(CommandLineProcessorFactory.PROFILE.DB, CommandLineProcessorFactory.PROFILE.REST_CLIENT, CommandLineProcessorFactory.PROFILE.COLLECTOR);
final LocalLogFileWriter write... | public static boolean copyFile(File dest, File source) {
FileInputStream fis = null;
FileOutputStream fos = null;
boolean rv = false;
byte[] buf = new byte[1000000];
int bytesRead = 0;
if (!dest.getParentFile().exists()) dest.getParentFile().mkdirs();
try {
... | true |
4,631 | 16,166,059 | 8,200,307 | 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 static String encryptPassword(String password) {
String hash = null;
try {
MessageDigest md = null;
md = MessageDigest.getInstance("SHA");
md.update(password.getBytes("UTF-8"));
byte raw[] = md.digest();
hash = Base64.encode(raw, fal... | false |
4,632 | 11,838,691 | 19,550,140 | private void externalizeFiles(Document doc, File out) throws IOException {
File[] files = doc.getImages();
if (files.length > 0) {
File dir = new File(out.getParentFile(), out.getName() + ".images");
if (!dir.mkdirs()) throw new IOException("cannot create directory " + dir);
... | private static void ensure(File pFile) throws IOException {
if (!pFile.exists()) {
FileOutputStream fos = new FileOutputStream(pFile);
String resourceName = "/" + pFile.getName();
InputStream is = BaseTest.class.getResourceAsStream(resourceName);
Assert.assert... | true |
4,633 | 22,403,259 | 12,787,570 | public 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();
... | private static void copyContent(final File srcFile, final File dstFile, final boolean gzipContent) throws IOException {
final File dstFolder = dstFile.getParentFile();
dstFolder.mkdirs();
if (!dstFolder.exists()) {
throw new RuntimeException("Unable to create the folder " + dstFo... | true |
4,634 | 4,672,830 | 325,062 | public static byte[] readFile(String filePath) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
FileInputStream is = new FileInputStream(filePath);
try {
IOUtils.copy(is, os);
return os.toByteArray();
} finally {
is.clos... | public void readMESHDescriptorFileIntoFiles(String outfiledir) {
String inputLine, ins;
String filename = getMESHdescriptorfilename();
String uid = "";
String name = "";
String description = "";
String element_of = "";
Vector treenr = new Vector();
Vec... | true |
4,635 | 23,677,118 | 4,672,830 | public static void copyFile5(File srcFile, File destFile) throws IOException {
InputStream in = new FileInputStream(srcFile);
OutputStream out = new FileOutputStream(destFile);
IOUtils.copyLarge(in, out);
in.close();
out.close();
}
| public static byte[] readFile(String filePath) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
FileInputStream is = new FileInputStream(filePath);
try {
IOUtils.copy(is, os);
return os.toByteArray();
} finally {
is.clos... | true |
4,636 | 16,116,214 | 11,872,567 | public static void processString(String text) throws Exception {
MessageDigest md5 = MessageDigest.getInstance(MD5_DIGEST);
md5.reset();
md5.update(text.getBytes());
displayResult(null, md5.digest());
}
| protected HttpResponseImpl makeRequest(final HttpMethod m, final String requestId) {
try {
HttpResponseImpl ri = new HttpResponseImpl();
ri.setRequestMethod(m);
ri.setResponseCode(_client.executeMethod(m));
ByteArrayOutputStream bos = new ByteArrayOutputStream... | false |
4,637 | 16,012,363 | 23,563,688 | public static void main(String[] args) throws IOException {
String uri = "hdfs://localhost:8020/user/leeing/maxtemp/sample.txt";
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), conf);
InputStream in = null;
try {
in = fs.o... | private void getLocationAddressByGoogleMapAsync(Location location) {
if (location == null) {
return;
}
AsyncTask<Location, Void, String> task = new AsyncTask<Location, Void, String>() {
@Override
protected String doInBackground(Location... params) {
... | false |
4,638 | 15,289,245 | 23,555,994 | public boolean checkTypeChange(Class<?> clazz, File buildDir, File refFile) throws MojoExecutionException {
if (!clazz.isPrimitive()) {
ClassLoader cl = clazz.getClassLoader();
if (cl == loader) {
if (clazz.isArray()) return checkTypeChange(getArrayType(clazz), buildD... | public OperandToken evaluate(Token[] operands, GlobalValues globals) {
String s = "";
String lineFile = "";
;
if (getNArgIn(operands) != 1) throwMathLibException("urlread: number of arguments < 1");
if (!(operands[0] instanceof CharToken)) throwMathLibException("urlread: argu... | false |
4,639 | 23,677,119 | 1,180,865 | public static void copyFile6(File srcFile, File destFile) throws FileNotFoundException {
Scanner s = new Scanner(srcFile);
PrintWriter pw = new PrintWriter(destFile);
while(s.hasNextLine()) {
pw.println(s.nextLine());
}
pw.close();
s.close();
}
| @Override
public void runTask(HashMap pjobParameters) throws Exception {
if (hasRequiredResources(isSubTask())) {
String lstrSource = getSourceFilename();
String lstrTarget = getTargetFilename();
if (getSourceDirectory() != null) {
lstrSource = getSour... | true |
4,640 | 17,492,434 | 3,660,402 | @Test
public void testProxySsl() throws Throwable {
URL url = new URL("https://login.yahoo.co.jp/config/login");
HttpsURLConnection httpsconnection = (HttpsURLConnection) url.openConnection();
KeyManager[] km = null;
TrustManager[] tm = { new X509TrustManager() {
pub... | public void importCertFile(File file) throws IOException {
File kd;
File cd;
synchronized (this) {
kd = keysDir;
cd = certsDir;
}
if (!cd.isDirectory()) {
kd.mkdirs();
cd.mkdirs();
}
String newName = file.getName... | false |
4,641 | 616,260 | 9,591,960 | 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... | protected Object serveFile(MyServerSocket socket, String filenm, URL url) {
PrintStream out = null;
InputStream in = null;
long len = 0;
try {
out = new PrintStream(socket.getOutputStream());
in = url.openStream();
len = in.available();
} c... | false |
4,642 | 12,312,915 | 11,958,349 | public static void entering(String[] args) throws IOException, CodeCheckException {
ClassWriter writer = new ClassWriter();
writer.readClass(new BufferedInputStream(new FileInputStream(args[0])));
int constantIndex = writer.getStringConstantIndex("Entering ");
int fieldRefIndex = wri... | public static void makeLPKFile(String[] srcFilePath, String makeFilePath, LPKHeader header) {
FileOutputStream os = null;
DataOutputStream dos = null;
try {
LPKTable[] fileTable = new LPKTable[srcFilePath.length];
long fileOffset = outputOffset(header);
fo... | true |
4,643 | 8,778,961 | 17,497,944 | 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 void format(File source, File target) {
if (!source.exists()) {
throw new IllegalArgumentException("Source '" + source + " doesn't exist");
}
if (!source.isFile()) {
throw new IllegalArgumentException("Source '" + source + " is not a file");
}
t... | true |
4,644 | 914,073 | 20,514,304 | public Configuration(URL url) {
InputStream in = null;
try {
load(in = url.openStream());
} catch (Exception e) {
throw new RuntimeException("Could not load configuration from " + url, e);
} finally {
if (in != null) {
try {
... | @SuppressWarnings("unchecked")
private Map<String, Object> _request(String method, String path, Map<String, Object> body, JSONRecognizer... recognizers) throws IOException, TwinException {
String uri = url + path;
HttpRequest request;
if (body == null) {
BasicHttpRequest r = ... | false |
4,645 | 18,731,110 | 18,560,649 | 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.... | private static final void addFile(ZipArchiveOutputStream os, File file, String prefix) throws IOException {
ArchiveEntry entry = os.createArchiveEntry(file, file.getAbsolutePath().substring(prefix.length() + 1));
os.putArchiveEntry(entry);
FileInputStream fis = new FileInputStream(file);
... | true |
4,646 | 982,157 | 14,956,500 | private InputStream getDomainMap() {
String domainMap = Configuration.getString(MAPPING_KEY);
InputStream is = new StringBufferInputStream(domainMap);
if ("".equals(domainMap)) {
try {
URL url = getClass().getResource(XML_FILE_NAME).toURI().toURL();
... | @Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("utf-8");
EntityManager em = EMF.get().createEntityManager();
String url = req.getRequestURL().toString();
... | false |
4,647 | 5,195,056 | 3,046,300 | public String getData() throws ValueFormatException, RepositoryException, IOException {
InputStream is = getStream();
StringWriter sw = new StringWriter();
IOUtils.copy(is, sw, "UTF-8");
IOUtils.closeQuietly(is);
return sw.toString();
}
| private void copyFileToPhotoFolder(File photo, String personId) {
try {
FileChannel in = new FileInputStream(photo).getChannel();
File dirServer = new File(Constants.PHOTO_DIR);
if (!dirServer.exists()) {
dirServer.mkdirs();
}
File ... | true |
4,648 | 17,534,703 | 3,634,782 | 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 static void main(String[] args) {
paraProc(args);
CanonicalGFF cgff = new CanonicalGFF(gffFilename);
CanonicalGFF geneModel = new CanonicalGFF(modelFilename);
CanonicalGFF transcriptGff = new CanonicalGFF(transcriptFilename);
TreeMap ksTable1 = getKsTable(ksTable1Filen... | true |
4,649 | 13,111,022 | 22,137,915 | private static void copy(File source, File target) throws IOException {
InputStream is = null;
OutputStream os = null;
try {
is = new BufferedInputStream(new FileInputStream(source));
os = new BufferedOutputStream(new FileOutputStream(target));
int b;
... | 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... | true |
4,650 | 17,076,120 | 7,793,684 | public String getTextData() {
if (tempFileWriter != null) {
try {
tempFileWriter.flush();
tempFileWriter.close();
FileReader in = new FileReader(tempFile);
StringWriter out = new StringWriter();
int len;
... | 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 |
4,651 | 4,773,756 | 849,586 | public void zipDocsetFiles(SaxHandler theXmlHandler, int theEventId, Attributes theAtts) throws BpsProcessException {
ZipOutputStream myZipOut = null;
BufferedInputStream myDocumentInputStream = null;
String myFinalFile = null;
String myTargetPath = null;
String myTargetFileN... | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | true |
4,652 | 22,303,544 | 10,392,922 | @Test
public void testWriteAndRead() throws Exception {
JCFSFileServer server = new JCFSFileServer(defaultTcpPort, defaultTcpAddress, defaultUdpPort, defaultUdpAddress, dir, 0, 0);
JCFS.configureDiscovery(defaultUdpAddress, defaultUdpPort);
try {
server.start();
R... | public static void copyCompletely(InputStream input, OutputStream output) throws IOException {
if ((output instanceof FileOutputStream) && (input instanceof FileInputStream)) {
try {
FileChannel target = ((FileOutputStream) output).getChannel();
FileChannel source... | true |
4,653 | 19,780,094 | 2,168,608 | protected PTask commit_result(Result r, SyrupConnection con) throws Exception {
try {
int logAction = LogEntry.ENDED;
String kk = r.context().task().key();
if (r.in_1_consumed() && r.context().in_1_link() != null) {
sqlImpl().updateFunctions().updateInLink... | public int delete(BusinessObject o) throws DAOException {
int delete = 0;
Contact contact = (Contact) o;
try {
PreparedStatement pst = connection.prepareStatement(XMLGetQuery.getQuery("DELETE_CONTACT"));
pst.setInt(1, contact.getId());
delete = pst.execute... | true |
4,654 | 16,713,229 | 18,385,066 | public void uploadFile(ActionEvent event) throws IOException {
InputFile inputFile = (InputFile) event.getSource();
synchronized (inputFile) {
ServletContext context = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
String fileNewPath = a... | public static Document getResponse(HttpClient client, HttpRequestBase request) {
try {
HttpResponse response = client.execute(request);
StatusLine statusLine = response.getStatusLine();
System.err.println(statusLine.getStatusCode() + " data: " + statusLine.getReasonPhrase... | false |
4,655 | 657,801 | 4,464,301 | void copyFile(String from, String to) throws IOException {
File destFile = new File(to);
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
... | protected void shutdown(final boolean unexpected) {
ControlerState oldState = this.state;
this.state = ControlerState.Shutdown;
if (oldState == ControlerState.Running) {
if (unexpected) {
log.warn("S H U T D O W N --- received unexpected shutdown request.");
... | true |
4,656 | 12,176,858 | 23,595,064 | void sortclasses() {
int i, j;
boolean domore;
vclassptr = new int[numc];
for (i = 0; i < numc; i++) vclassptr[i] = i;
domore = true;
while (domore == true) {
domore = false;
for (i = 0; i < numc - 1; i++) {
if (vclassctr[vclass... | public void writeTo(OutputStream out) throws IOException {
if (!closed) {
throw new IOException("Stream not closed");
}
if (isInMemory()) {
memoryOutputStream.writeTo(out);
} else {
FileInputStream fis = new FileInputStream(outputFile);
... | false |
4,657 | 3,223,173 | 831,650 | public Book importFromURL(URL url) {
InputStream is = null;
try {
is = url.openStream();
return importFromStream(is, url.toString());
} catch (Exception ex) {
throw ModelException.Aide.wrap(ex);
} finally {
if (is != null) {
... | 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.... | false |
4,658 | 341,023 | 12,734,324 | private String encryptPassword(String password) throws NoSuchAlgorithmException {
MessageDigest encript = MessageDigest.getInstance("MD5");
encript.update(password.getBytes());
byte[] b = encript.digest();
int size = b.length;
StringBuffer h = new StringBuffer(size);
... | public static String post(String url, Map params, String line_delimiter) {
String response = "";
try {
URL _url = new URL(url);
URLConnection conn = _url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getO... | false |
4,659 | 20,825,513 | 3,501,612 | private String md5(String pass) {
StringBuffer enteredChecksum = new StringBuffer();
byte[] digest;
MessageDigest md5;
try {
md5 = MessageDigest.getInstance("MD5");
md5.update(pass.getBytes(), 0, pass.length());
digest = md5.digest();
f... | char[] DigestCalcResponse(char[] HA1, String serverNonce, String nonceCount, String clientNonce, String qop, String method, String digestUri, boolean clientResponseFlag) throws SaslException {
byte[] HA2;
byte[] respHash;
char[] HA2Hex;
try {
MessageDigest md = MessageDig... | true |
4,660 | 19,130,322 | 15,741,989 | 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... | public String encrypt(String password) {
if (password.length() == 40) {
return password;
}
if (salt != null) {
password = password + salt;
}
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("SHA1")... | true |
4,661 | 22,243,603 | 13,086,935 | @Override
protected PermissionCollection getPermissions(CodeSource _codeSource) {
PermissionCollection perms = super.getPermissions(_codeSource);
URL url = _codeSource.getLocation();
Permission perm = null;
URLConnection urlConnection = null;
try {
urlConnecti... | private void getInfoFromXML() {
final ProgressDialog dialog = ProgressDialog.show(this, "", getString(R.string.loading), true, true);
setProgressBarIndeterminateVisibility(true);
Thread t3 = new Thread() {
public void run() {
waiting(200);
txtinfo... | false |
4,662 | 20,189,177 | 8,250,731 | private static void stampaFoglioRisposte(HttpSession httpSess, Appelli appello, Elaborati el, StringBuffer retVal, boolean primaVolta, String url, boolean anonimo) {
InputStream is = null;
String html = null;
final int MAX_RIGHE_PER_PAGINA = 25;
long totaleDomande = EsamiDAO.trovaQua... | @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String uuid = req.getParameterValues(Constants.PARAM_UUID)[0];
String datastream = null;
if (req.getRequestURI().contains(Constants.SERVLET_DOWNLOAD_FOXML_PREFIX)) {
... | false |
4,663 | 8,787,103 | 10,473,584 | private void headinfoThread() {
try {
URLConnection urlc = resource.url.openConnection();
resource.setFileSize(urlc.getContentLength());
resource.setDate(urlc.getLastModified());
} catch (IOException e) {
System.out.println("Error ResourceConnection, d... | public ValidationReport validate(OriginalDeployUnitDescription unit) throws UnitValidationException {
ValidationReport vr = new DefaultValidationReport();
errorHandler = new SimpleErrorHandler(vr);
vr.setFileUri(unit.getAbsolutePath());
SAXParser parser;
SAXReader reader = nu... | false |
4,664 | 786,782 | 2,691,849 | public void _getPlotTypes() {
boolean gotPlots = false;
while (!gotPlots) {
try {
_myPlotTypes = new Vector[2];
_myPlotTypes[0] = new Vector();
_myPlotTypes[1] = new Vector();
URL dataurl = new URL(getDocumentBase(), plotTyp... | public static void compress(final File zip, final Map<InputStream, String> entries, final IProgressMonitor monitor) throws IOException {
if (zip == null || entries == null || CollectionUtils.isEmpty(entries.keySet())) throw new IllegalArgumentException("One ore more parameters are empty!");
if (zip.... | false |
4,665 | 11,929,030 | 23,206 | public T_Result unmarshall(URL url) throws SAXException, ParserConfigurationException, IOException {
XMLReader parser = getParserFactory().newSAXParser().getXMLReader();
parser.setContentHandler(getContentHandler());
parser.setDTDHandler(getContentHandler());
parser.setEntityResolver... | public static BufferedReader getUserInfoStream(String name) throws IOException {
BufferedReader in;
try {
URL url = new URL("http://www.spoj.pl/users/" + name.toLowerCase() + "/");
in = new BufferedReader(new InputStreamReader(url.openStream()));
} catch (MalformedURL... | false |
4,666 | 10,113,882 | 9,756,057 | private void createSaveServiceProps() throws MojoExecutionException {
saveServiceProps = new File(workDir, "saveservice.properties");
try {
FileWriter out = new FileWriter(saveServiceProps);
IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("save... | public void writeToFile(File out) throws IOException, DocumentException {
FileChannel inChannel = new FileInputStream(pdf_file).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} ca... | true |
4,667 | 16,083,957 | 13,354,644 | protected void createValueListAnnotation(IProgressMonitor monitor, IPackageFragment pack, Map model) throws CoreException {
IProject pj = pack.getJavaProject().getProject();
QualifiedName qn = new QualifiedName(JstActivator.PLUGIN_ID, JstActivator.PACKAGE_INFO_LOCATION);
String location = pj... | public void addUrl(URL url) throws IOException, SAXException {
InputStream inStream = url.openStream();
String path = url.getPath();
int slashInx = path.lastIndexOf('/');
String name = path.substring(slashInx + 1);
Document doc = docBuild.parse(inStream);
Element root... | false |
4,668 | 17,662,180 | 4,456,641 | public XlsBook(String path) throws IOException {
boolean isHttp = path.startsWith("http://");
InputStream is = null;
if (isHttp) {
URL url = new URL(path);
is = url.openStream();
} else {
File file = new File(path);
is = new FileInputSt... | private void copyFile(File srcFile, File destFile) throws IOException {
if (!(srcFile.exists() && srcFile.isFile())) throw new IllegalArgumentException("Source file doesn't exist: " + srcFile.getAbsolutePath());
if (destFile.exists() && destFile.isDirectory()) throw new IllegalArgumentException("Des... | false |
4,669 | 7,046,481 | 14,317,426 | public InlineImageChunk(URL url) {
super();
this.url = url;
try {
URLConnection urlConn = url.openConnection();
urlConn.setReadTimeout(15000);
ImageInputStream iis = ImageIO.createImageInputStream(urlConn.getInputStream());
Iterator<ImageReader... | 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.... | false |
4,670 | 8,759,736 | 7,093,300 | public File convert(URI uri) throws DjatokaException {
processing.add(uri.toString());
File urlLocal = null;
try {
logger.info("processingRemoteURI: " + uri.toURL());
boolean isJp2 = false;
InputStream src = IOUtils.getInputStream(uri.toURL());
... | public static InputStream getRequest(String path) throws Exception {
HttpGet httpGet = new HttpGet(path);
HttpResponse httpResponse = sClient.execute(httpGet);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(httpResponse.getEnti... | false |
4,671 | 23,594,635 | 22,307,321 | private void copyFileToPhotoFolder(File photo, String personId) {
try {
FileChannel in = new FileInputStream(photo).getChannel();
File dirServer = new File(Constants.PHOTO_DIR);
if (!dirServer.exists()) {
dirServer.mkdirs();
}
File ... | public static String crypt(String target) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(target.getBytes("UTF-16"));
BigInteger res = new BigInteger(1, md.digest(key.getBytes()));
return res.toString(16);... | false |
4,672 | 10,721,234 | 22,930,145 | private String handleRequest(String url, boolean get) {
HttpURLConnection c = null;
InputStream is = null;
ByteArrayInputStream bais;
byte[] buf;
String temp, ret = "";
int response, len, i;
try {
c = (HttpURLConnection) new URL(url).openConnection... | private long getLastModification() {
try {
if (connection == null) connection = url.openConnection();
return connection.getLastModified();
} catch (IOException e) {
LOG.warn("URL could not be opened: " + e.getMessage(), e);
return 0;
}
}
| false |
4,673 | 16,069,454 | 8,274,572 | public int add(WebService ws) throws FidoDatabaseException {
try {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
String sql = "insert into WebServices (MethodName, ServiceURI) " + "values ('" + ws.getMethodName() + "... | public ODFSignatureService(TimeStampServiceValidator timeStampServiceValidator, RevocationDataService revocationDataService, SignatureFacet signatureFacet, InputStream documentInputStream, OutputStream documentOutputStream, TimeStampService timeStampService, String role, IdentityDTO identity, byte[] photo, DigestAl... | false |
4,674 | 7,842,021 | 16,579,945 | public FileInputStream execute() {
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
String pdfPath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/pdf");
try {... | public he3Decode(String in_file) {
try {
File out = new File(in_file + extension);
File in = new File(in_file);
int file_size = (int) in.length();
FileInputStream in_stream = new FileInputStream(in_file);
out.createNewFile();
FileOutput... | true |
4,675 | 5,634,854 | 20,508,694 | private static void checkClients() {
try {
sendMultiListEntry('l');
} catch (Exception e) {
if (Util.getDebugLevel() > 90) e.printStackTrace();
}
try {
if (CANT_CHECK_CLIENTS != null) KeyboardHero.removeStatus(CANT_CHECK_CLIENTS);
URL u... | private void tar(FileHolder fileHolder, boolean gzipIt) {
byte[] buffer = new byte[BUFFER_SIZE];
int bytes_read;
if (fileHolder.selectedFileList.size() == 0) {
return;
}
File tarDestFile = new File(fileHolder.destFiles[0]);
try {
OutputStream o... | false |
4,676 | 3,375,720 | 1,139,230 | public void importarHistoricoDoPIB(Andamento pAndamento) throws FileNotFoundException, SQLException, Exception {
pAndamento.delimitarIntervaloDeVariacao(0, 49);
PIB[] valoresPendentesDoPIB = obterValoresPendentesDoPIB(pAndamento);
pAndamento.delimitarIntervaloDeVariacao(50, 100);
if ... | public static File copyFile(File srcFile, File destFolder, FileCopyListener copyListener) {
File dest = new File(destFolder, srcFile.getName());
try {
FileInputStream in = new FileInputStream(srcFile);
FileOutputStream out = new FileOutputStream(dest);
byte[] read... | false |
4,677 | 1,002,618 | 14,406,880 | public void run() {
if (withlinlyn == true) {
try {
xlin.erase(file);
} catch (Exception e) {
System.out.println("Error erasing");
}
} else if (as_php) {
try {
URL url = new URL(http + "REM:" + pservname)... | @Override
public void setDocumentSpace(DocumentSpace space) {
for (Document doc : space) {
if (doc instanceof XMLDOMDocument) {
writer.writeDocument(doc);
} else if (doc instanceof BinaryDocument) {
BinaryDocument bin = (BinaryDocument) doc;
... | false |
4,678 | 9,837,783 | 22,321,272 | private void fileCopier(String filenameFrom, String filenameTo) {
FileInputStream fromStream = null;
FileOutputStream toStream = null;
try {
fromStream = new FileInputStream(new File(filenameFrom));
if (new File(filenameTo).exists()) {
new File(filenam... | public static void copyFile(File from, File to) throws Exception {
if (!from.exists()) return;
FileInputStream in = new FileInputStream(from);
FileOutputStream out = new FileOutputStream(to);
byte[] buffer = new byte[BUFFER_SIZE];
int bytes_read;
while (true) {
... | true |
4,679 | 20,953,665 | 337,322 | private void packageDestZip(File tmpFile) throws FileNotFoundException, IOException {
log("Creating launch profile package " + destfile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destfile)));
ZipEntry e = new ZipEntry(RESOURCE_JAR_FILENAME);
... | 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... | true |
4,680 | 7,051,649 | 253,661 | private void copyFile(String inputPath, String basis, String filename) throws GLMRessourceFileException {
try {
FileChannel inChannel = new FileInputStream(new File(inputPath)).getChannel();
File target = new File(basis, filename);
FileChannel outChannel = new FileOutputS... | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | true |
4,681 | 11,670,354 | 17,334,846 | public ABIFile(URL url) throws FileFormatException, IOException {
URLConnection connection = url.openConnection();
int contentLength = connection.getContentLength();
if (contentLength <= 0) throw new RuntimeException(url + " contained no content");
byte[] content = new byte[contentLe... | static String encodeEmailAsUserId(String email) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(email.toLowerCase().getBytes());
StringBuilder builder = new StringBuilder();
builder.append("1");
for (byte b : md5.digest()) ... | false |
4,682 | 21,704,695 | 5,297,820 | public String hmacSHA256(String message, byte[] key) {
MessageDigest sha256 = null;
try {
sha256 = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw new java.lang.AssertionError(this.getClass().getName() + ".hmacSHA256(): SHA-256 algor... | public static void copyFile(File src, File dst) throws IOException {
FileChannel from = new FileInputStream(src).getChannel();
FileChannel to = new FileOutputStream(dst).getChannel();
from.transferTo(0, src.length(), to);
from.close();
to.close();
}
| false |
4,683 | 6,569,409 | 14,864,066 | public String obfuscateString(String string) {
String obfuscatedString = null;
try {
MessageDigest md = MessageDigest.getInstance(ENCRYPTION_ALGORITHM);
md.update(string.getBytes());
byte[] digest = md.digest();
obfuscatedString = new String(Base64.enc... | protected boolean downloadFile(TestThread thread, ActionResult result) {
result.setRequestString("download file " + remoteFile);
InputStream input = null;
OutputStream output = null;
OutputStream target = null;
boolean status = false;
ftpClient.enterLocalPassiveMode()... | false |
4,684 | 20,250,217 | 7,039,646 | private byte[] getBytesFromUrl(URL url) {
ByteArrayOutputStream bais = new ByteArrayOutputStream();
InputStream is = null;
try {
is = url.openStream();
byte[] byteChunk = new byte[4096];
int n;
while ((n = is.read(byteChunk)) > 0) {
... | private static final void cloneFile(File origin, File target) throws IOException {
FileChannel srcChannel = null;
FileChannel destChannel = null;
try {
srcChannel = new FileInputStream(origin).getChannel();
destChannel = new FileOutputStream(target).getChannel();
... | false |
4,685 | 3,357,695 | 4,519,452 | public void readCatalog(Catalog catalog, String fileUrl) throws MalformedURLException, IOException, CatalogException {
URL url = null;
try {
url = new URL(fileUrl);
} catch (MalformedURLException e) {
url = new URL("file:///" + fileUrl);
}
debug = cata... | private void copyFile(File s, File d) throws IOException {
d.getParentFile().mkdirs();
FileChannel inChannel = new FileInputStream(s).getChannel();
FileChannel outChannel = new FileOutputStream(d).getChannel();
int maxCount = (64 * 1024 * 1024) - (32 * 1024);
long size = inCh... | false |
4,686 | 15,260,218 | 5,494,012 | public static String md5Encode16(String s) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(s.getBytes("utf-8"));
byte b[] = md.digest();
int i;
StringBuilder buf = new StringBuilder("");
for (int offset = 0; offse... | private String doMessageDigestAndBase64Encoding(String sequence) throws SeguidException {
if (sequence == null) {
throw new NullPointerException("You must give a non null sequence");
}
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA");
s... | true |
4,687 | 9,909,126 | 9,061,980 | public void service(TranslationRequest request, TranslationResponse response) {
try {
Thread.sleep((long) Math.random() * 250);
} catch (InterruptedException e1) {
}
hits.incrementAndGet();
String key = getKey(request);
RequestResponse cachedResponse = cac... | public static void copyFile(String source, String destination, TimeSlotTracker timeSlotTracker) {
LOG.info("copying [" + source + "] to [" + destination + "]");
BufferedInputStream sourceStream = null;
BufferedOutputStream destStream = null;
try {
File destinationFile = n... | true |
4,688 | 3,054,600 | 20,085,210 | private void generateArchetype(final IProject project, final IDataModel model, final IProgressMonitor monitor, final boolean offline) throws CoreException, InterruptedException, IOException {
if (getArchetypeArtifactId(model) != null) {
final Properties properties = new Properties();
... | 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(... | true |
4,689 | 23,299,951 | 19,090,290 | private void readFromFile1() throws DException {
URL url1 = null;
if (url == null) {
url = getClass().getResource("/com/daffodilwoods/daffodildb/utils/parser/parser.schema");
try {
url = new URL(url.getProtocol() + ":" + url.getPath().substring(0, url.getPath(... | public static Channel getChannelFromXML(String channelURL) throws SAXException, IOException {
channel = new Channel(channelURL);
downloadedItems = new LinkedList<Item>();
URL url = new URL(channelURL);
XMLReader xr = XMLReaderFactory.createXMLReader();
ChannelFactory handler ... | false |
4,690 | 4,076,627 | 21,836,608 | public void openFtpConnection(String workingDirectory) throws RQLException {
try {
ftpClient = new FTPClient();
ftpClient.connect(server);
ftpClient.login(user, password);
ftpClient.changeWorkingDirectory(workingDirectory);
} catch (IOException ioex) {... | private void connect() throws Exception {
if (client != null) throw new IllegalStateException("Already connected.");
try {
_logger.debug("About to connect to ftp server " + server + " port " + port);
client = new FTPClient();
client.connect(server, port);
... | true |
4,691 | 8,385,051 | 17,857,284 | public void play() throws FileNotFoundException, IOException, NoSuchAlgorithmException, FTPException {
final int BUFFER = 2048;
String host = "ftp.genome.jp";
String username = "anonymous";
String password = "";
FTPClient ftp = null;
ftp = new FTPClient();
ftp... | 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 |
4,692 | 10,524,166 | 21,519,782 | public static void copyURLToFile(URL source, File destination) throws IOException {
InputStream input = source.openStream();
try {
FileOutputStream output = openOutputStream(destination);
try {
IOUtils.copy(input, output);
} finally {
... | protected static void copyDeleting(File source, File dest) throws ErrorCodeException {
byte[] buf = new byte[8 * 1024];
FileInputStream in = null;
try {
in = new FileInputStream(source);
try {
FileOutputStream out = new FileOutputStream(dest);
... | true |
4,693 | 13,447,231 | 17,832,320 | public void copy(String pathFileIn, String pathFileOut) {
try {
File inputFile = new File(pathFileIn);
File outputFile = new File(pathFileOut);
FileReader in = new FileReader(inputFile);
File outDir = new File(DirOut);
if (!outDir.exists()) outDir.... | public void run() {
Pair p = null;
try {
while ((p = queue.pop()) != null) {
GetMethod get = new GetMethod(p.getRemoteUri());
try {
get.setFollowRedirects(true);
get.setRequestHeader("Mariner-Application", "prerender... | true |
4,694 | 210,587 | 19,715,255 | 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... | static Object executeMethod(HttpMethod method, int timeout, boolean array) throws HttpRequestFailureException, HttpException, IOException, HttpRequestTimeoutException {
try {
method.getParams().setSoTimeout(timeout * 1000);
int status = -1;
Object result = null;
... | true |
4,695 | 18,042,543 | 4,056,440 | 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 final String hashPassword(final String password) {
try {
if (salt == null) {
salt = new byte[16];
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
sr.setSeed(System.currentTimeMillis());
sr.... | false |
4,696 | 11,922,877 | 14,341,904 | private void chooseGame(DefaultHttpClient httpclient) throws IOException, ClientProtocolException {
HttpGet httpget = new HttpGet(Constants.STRATEGICDOMINATION_URL + "/gameboard.cgi?gameid=" + 1687);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity(... | private static void copyFile(String from, String to) throws IOException {
FileReader in = new FileReader(from);
FileWriter out = new FileWriter(to);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
out.close();
}
| true |
4,697 | 16,767,036 | 7,067,729 | private void loadProperties() {
if (properties == null) {
properties = new Properties();
try {
URL url = getClass().getResource(propsFile);
if (url != null) properties.load(url.openStream());
} catch (IOException ioe) {
ioe.... | public void loadScripts() {
org.apache.batik.script.Window window = null;
NodeList scripts = document.getElementsByTagNameNS(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SCRIPT_TAG);
int len = scripts.getLength();
if (len == 0) {
return;
}
for (int i =... | false |
4,698 | 21,644,149 | 23,048,529 | public void downloadQFromMinibix(int ticketNo) {
String minibixDomain = Preferences.userRoot().node("Spectatus").get("MBAddr", "http://mathassess.caret.cam.ac.uk");
String minibixPort = Preferences.userRoot().node("Spectatus").get("MBPort", "80");
String url = minibixDomain + ":" + minibixPo... | 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... | false |
4,699 | 6,983,973 | 4,084,832 | 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);
}
... | public void send() {
final String urlPath = "/rest/nodes/";
final String preIsy99Cmd = "/cmd/";
String urlStr = null;
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
httpclient.getCredentialsProvider().setCredentials(new AuthScope(host, 80), new User... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.