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,100 | 18,695,537 | 14,667,674 | public InputSource resolveEntity(String pPublicId, String pSystemId) throws SAXException, IOException {
try {
URL url = new URL(pSystemId);
String fileName = (String) urlMap.get(url);
if (fileName != null) {
FileInputStream istream ... | @Override
protected FTPClient ftpConnect() throws SocketException, IOException, NoSuchAlgorithmException {
FilePathItem fpi = getFilePathItem();
FTPClient f = new FTPSClient();
f.connect(fpi.getHost());
f.login(fpi.getUsername(), fpi.getPassword());
return f;
}
| false |
1,101 | 6,988,217 | 22,950,123 | public void testQueryForBinary() throws InvalidNodeTypeDefException, ParseException, Exception {
JCRNodeSource source = (JCRNodeSource) resolveSource(BASE_URL + "images/photo.png");
assertNotNull(source);
assertEquals(false, source.exists());
OutputStream os = source.getOutputStream(... | private boolean exportPKC(String keystoreLocation, String pw) {
boolean created = false;
KeyStore ks = null;
try {
ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new BufferedInputStream(new FileInputStream(keystoreLocation)), pw.toCharArray());
... | true |
1,102 | 22,484,885 | 9,135,964 | private void initClientConfigurationFromURL(String urlStr) throws Exception {
try {
URL url = ProxyURLFactory.createHttpUrl(urlStr);
initClientConfiguration(url.openStream());
} catch (Exception e) {
throw new Exception("Could not initialize from Client Configurat... | private BufferedReader getReader(final String fileUrl) throws IOException {
InputStreamReader reader;
try {
reader = new FileReader(fileUrl);
} catch (FileNotFoundException e) {
URL url = new URL(fileUrl);
reader = new InputStreamReader(url.openStream());
... | false |
1,103 | 11,279,071 | 8,908,943 | public static String getSHA1Digest(String inputStr) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = null;
byte[] sha1hash = null;
md = MessageDigest.getInstance("SHA");
sha1hash = new byte[40];
md.update(inputStr.getBytes("iso-8859-1"), 0, i... | public static String GetMD5SUM(String s) throws NoSuchAlgorithmException {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(s.getBytes());
byte messageDigest[] = algorithm.digest();
String md5sum = Base64.encode(messageDigest);
... | true |
1,104 | 19,870,772 | 536,222 | @RequestMapping(value = "/verdocumentoFisico.html", method = RequestMethod.GET)
public String editFile(ModelMap model, @RequestParam("id") int idAnexo) {
Anexo anexo = anexoService.selectById(idAnexo);
model.addAttribute("path", anexo.getAnexoCaminho());
try {
InputStream is ... | 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,105 | 970,144 | 18,935,118 | public Logging() throws Exception {
File home = new File(System.getProperty("user.home"), ".jorgan");
if (!home.exists()) {
home.mkdirs();
}
File logging = new File(home, "logging.properties");
if (!logging.exists()) {
InputStream input = getClass().ge... | public boolean backupFile(File oldFile, File newFile) {
boolean isBkupFileOK = false;
FileChannel sourceChannel = null;
FileChannel targetChannel = null;
try {
sourceChannel = new FileInputStream(oldFile).getChannel();
targetChannel = new FileOutputStream(newF... | true |
1,106 | 6,371,595 | 15,168,184 | public void setUserPassword(final List<NewUser> users) {
try {
final List<Integer> usersToRemoveFromCache = new ArrayList<Integer>();
connection.setAutoCommit(false);
new ProcessEnvelope().executeNull(new ExecuteProcessAbstractImpl(connection, false, false, true, true) {
... | public void copyServer(int id) throws Exception {
File in = new File("servers" + File.separatorChar + "server_" + id);
File serversDir = new File("servers" + File.separatorChar);
int newNumber = serversDir.listFiles().length + 1;
System.out.println("New File Number: " + newNumber);
... | false |
1,107 | 13,396,233 | 10,535,319 | public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} catch (IOExcep... | private static Collection<String> createTopLevelFiles(Configuration configuration, Collections collections, Sets sets) throws FlickrException, SAXException, IOException, JDOMException, TransformerException {
Collection<String> createdFiles = new HashSet<String>();
File toplevelXmlFilename = getTople... | true |
1,108 | 5,339,736 | 20,681,844 | public static String translate(String s) {
try {
String result = null;
URL url = new URL("http://translate.google.com/translate_t");
URLConnection connection = url.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0... | public void testGetOldVersion() throws ServiceException, IOException, SAXException, ParserConfigurationException {
JCRNodeSource emptySource = loadTestSource();
for (int i = 0; i < 3; i++) {
OutputStream sourceOut = emptySource.getOutputStream();
InputStream contentIn = getCl... | false |
1,109 | 7,760,801 | 7,635,628 | 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 void bubbleSort(int values[]) {
int len = values.length - 1;
for (int i = 0; i < len; i++) {
for (int j = 0; j < len - i; j++) {
if (values[j] > values[j + 1]) {
int tmp = values[j];
values[j] = values[j + 1];
... | false |
1,110 | 5,620,793 | 5,371,059 | public static byte[] SHA1byte(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md;
md = MessageDigest.getInstance("SHA-1");
byte[] sha1hash = new byte[40];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
sha1hash = md.digest... | public static String digest(String value, String algorithm) throws Exception {
MessageDigest algo = MessageDigest.getInstance(algorithm);
algo.reset();
algo.update(value.getBytes("UTF-8"));
return StringTool.byteArrayToString(algo.digest());
}
| true |
1,111 | 21,212,076 | 16,706,336 | private void readParameterTable() {
if (this.parameters != null) return;
parameters = new GribPDSParameter[NPARAMETERS];
int center;
int subcenter;
int number;
try {
BufferedReader br;
if (filename != null && filename.length() > 0) {
... | protected URLConnection openConnection(URL url) throws IOException {
URLConnection con = url.openConnection();
if ("HTTPS".equalsIgnoreCase(url.getProtocol())) {
HttpsURLConnection scon = (HttpsURLConnection) con;
try {
scon.setSSLSocke... | false |
1,112 | 564,191 | 330,896 | private void processOrder() {
double neg = 0d;
if (intMode == MODE_CHECKOUT) {
if (round2Places(mBuf.getBufferTotal()) >= round2Places(order.getOrderTotal())) {
double cash, credit, allowedCredit = 0d;
allowedCredit = getStudentCredit();
if... | 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) {
... | false |
1,113 | 10,521,243 | 9,561,059 | public String md5(String phrase) {
MessageDigest m;
String coded = new String();
try {
m = MessageDigest.getInstance("MD5");
m.update(phrase.getBytes(), 0, phrase.length());
coded = (new BigInteger(1, m.digest()).toString(16)).toString();
} catch (... | private static byte[] createHash(EHashType hashType, String string) {
MessageDigest md;
try {
md = MessageDigest.getInstance(hashType.getJavaHashType());
md.reset();
md.update(string.getBytes());
byte[] byteResult = md.digest();
return byte... | true |
1,114 | 12,445,282 | 4,726,770 | static boolean writeProperties(Map<String, String> customProps, File destination) throws IOException {
synchronized (PropertiesIO.class) {
L.info(Msg.msg("PropertiesIO.writeProperties.start"));
File tempFile = null;
BufferedInputStream existingCfgInStream = null;
... | public void execute() throws MojoExecutionException, MojoFailureException {
try {
this.getLog().info("copy source web.xml - " + this.getWebXml() + " to build dir (source web.xml required if mergewebxml execution is enabled)");
File destination = new File(this.getBuildDir(), "web.xml"... | true |
1,115 | 17,374,904 | 11,026,173 | protected void saveSelectedFiles() {
if (dataList.getSelectedRowCount() == 0) {
return;
}
if (dataList.getSelectedRowCount() == 1) {
Object obj = model.getItemAtRow(sorter.convertRowIndexToModel(dataList.getSelectedRow()));
AttachFile entry = (AttachFile) ... | public static URLConnection getURLConnection(URL url, boolean ignoreBadCertificates) throws KeyManagementException, NoSuchAlgorithmException, UnknownHostException, IOException {
SSLSocketFactory sslSocketFactory = null;
if (ignoreBadCertificates) {
SSLContext sslContext = SSLContext.getI... | false |
1,116 | 20,438,542 | 16,832,679 | public static Shader loadShader(String vspath, String fspath, int textureUnits, boolean separateCam, boolean fog) throws ShaderProgramProcessException {
if (vspath == "" || fspath == "") return null;
BufferedReader in;
String vert = "", frag = "";
try {
URL v_url = Graphi... | public byte[] getXQueryForWorkflow(String workflowURI, Log4JLogger log) throws MalformedURLException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
if (workflowURI == null) {
throw new XQGeneratorException("Null workflow URI");
}
URL url = ... | false |
1,117 | 6,218,856 | 21,937,981 | public static Bitmap loadBitmap(String url) {
try {
final HttpClient httpClient = getHttpClient();
final HttpResponse resp = httpClient.execute(new HttpGet(url));
final HttpEntity entity = resp.getEntity();
final int statusCode = resp.getStatusLine().getStatus... | private void process(String zipFileName, String directory, String db) throws SQLException {
InputStream in = null;
try {
if (!FileUtils.exists(zipFileName)) {
throw new IOException("File not found: " + zipFileName);
}
String originalDbName = null;
... | false |
1,118 | 6,780,166 | 1,026,385 | public static void copyFile(File source, File destination) {
if (!source.exists()) {
return;
}
if ((destination.getParentFile() != null) && (!destination.getParentFile().exists())) {
destination.getParentFile().mkdirs();
}
try {
FileChannel... | public String transmit(String input, String filePath) throws Exception {
if (cookie == null || "".equals(urlString)) {
return null;
}
String txt = "";
StringBuffer returnMessage = new StringBuffer();
final String boundary = String.valueOf(System.currentTimeMillis(... | false |
1,119 | 10,482,004 | 430,971 | public static void main(String[] args) throws IOException {
System.out.println("Start filtering zgps...");
final Config config = ConfigUtils.loadConfig(args[0]);
final String CONFIG_MODULE = "GPSFilterZGPS";
File sourceFileSelectedStages = new File(config.findParam(CONFIG_MODULE, "so... | 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,120 | 21,364,786 | 2,238,218 | public boolean isPasswordValid(String encPass, String rawPass, Object salt) throws DataAccessException {
boolean bMatch = false;
try {
String strSalt = (String) salt;
byte[] baSalt = Hex.decodeHex(strSalt.toCharArray());
MessageDigest md = MessageDigest.getInstanc... | public void includeCss(Group group, Writer out, PageContext pageContext) throws IOException {
ByteArrayOutputStream outtmp = new ByteArrayOutputStream();
if (AbstractGroupBuilder.getInstance().buildGroupJsIfNeeded(group, outtmp, pageContext.getServletContext())) {
FileOutputStream fileSt... | false |
1,121 | 21,933,390 | 19,549,575 | public static List<String> getServers() throws Exception {
List<String> servers = new ArrayList<String>();
URL url = new URL("http://tfast.org/en/servers.php");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line = null;
while ((line =... | protected InputStream callApiGet(String apiUrl, int expected) {
try {
URL url = new URL(apiUrl);
HttpURLConnection request = (HttpURLConnection) url.openConnection();
if (ApplicationConstants.CONNECT_TIMEOUT > -1) {
request.setConnectTimeout(ApplicationCon... | true |
1,122 | 22,323,688 | 17,722,894 | 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 static String loadResource(String resource) {
URL url = ClassLoader.getSystemResource("resources/" + resource);
StringBuffer buffer = new StringBuffer();
if (url == null) {
ErrorMessage.handle(new NullPointerException("URL for resources/" + resource + " not found"));
... | true |
1,123 | 18,640,710 | 17,630,905 | private void sortWhats(String[] labels, int[] whats, String simplifyString) {
int n = whats.length;
boolean swapped;
do {
swapped = false;
for (int i = 0; i < n - 1; i++) {
int i0_pos = simplifyString.indexOf(labels[whats[i]]);
int i1_p... | public static int[] sortAscending(int input[]) {
int[] order = new int[input.length];
for (int i = 0; i < order.length; i++) order[i] = i;
for (int i = input.length; --i >= 0; ) {
for (int j = 0; j < i; j++) {
if (input[j] > input[j + 1]) {
int... | true |
1,124 | 278,685 | 5,105,540 | 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 {
... | public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException {
if (TDebug.TraceAudioFileReader) {
TDebug.out("MpegAudioFileReader.getAudioInputStream(URL): begin");
}
long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
URLConnect... | false |
1,125 | 18,492,103 | 16,987,999 | public void shouldAllowClosingInputStreamTwice() throws IOException {
OutputStream outputStream = fileSystem.createOutputStream(_("hello"), OutputMode.OVERWRITE);
outputStream.write(new byte[] { 1, 2, 3 });
outputStream.close();
InputStream inputStream = fileSystem.createInputStream(... | private void copyFile(File sourceFile, File destFile) throws IOException {
if (!sourceFile.exists()) {
return;
}
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
source = n... | true |
1,126 | 21,150,258 | 14,869,434 | private String convert(InputStream input, String encoding) throws Exception {
Process p = Runtime.getRuntime().exec("tidy -q -f /dev/null -wrap 0 --output-xml yes --doctype omit --force-output true --new-empty-tags " + emptyTags + " --quote-nbsp no -utf8");
Thread t = new CopyThread(input, p.getOut... | @Override
public void run() {
try {
FileChannel in = new FileInputStream(inputfile).getChannel();
long pos = 0;
for (int i = 1; i <= noofparts; i++) {
FileChannel out = new FileOutputStream(outputfile.getAbsolutePath() + "." + "v" + i).getChannel();
... | true |
1,127 | 16,386,620 | 3,667,135 | public static void main(String[] args) {
try {
FileReader reader = new FileReader(args[0]);
FileWriter writer = new FileWriter(args[1]);
html2xhtml(reader, writer);
writer.close();
reader.close();
} catch (Exception e) {
freemin... | public void fileCopy(File inFile, File outFile) {
try {
FileInputStream in = new FileInputStream(inFile);
FileOutputStream out = new FileOutputStream(outFile);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
out.close();
... | true |
1,128 | 6,453,383 | 1,152,136 | @Override
public TDSScene loadScene(URL url) throws IOException, IncorrectFormatException, ParsingErrorException {
boolean baseURLWasNull = setBaseURLFromModelURL(url);
TDSScene scene = loadScene(url.openStream());
if (baseURLWasNull) {
popBaseURL();
}
return ... | @SuppressWarnings("unchecked")
public ArrayList<GmailContact> getAllContacts() throws GmailException {
String query = properties.getString("export_page");
query = query.replace("[RANDOM_INT]", "" + random.nextInt());
int statusCode = -1;
GetMethod get = new GetMethod(query);
... | false |
1,129 | 8,359,774 | 941,896 | public static void bubbleSort(int[] a) {
if (a == null) {
throw new IllegalArgumentException("Null-pointed array");
}
int right = a.length - 1;
int k = 0;
while (right > 0) {
k = 0;
for (int i = 0; i <= right - 1; i++) {
if ... | 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... | false |
1,130 | 22,556,551 | 5,422,086 | private void copyOneFile(String oldPath, String newPath) {
File copiedFile = new File(newPath);
try {
FileInputStream source = new FileInputStream(oldPath);
FileOutputStream destination = new FileOutputStream(copiedFile);
FileChannel sourceFileChannel = source.get... | public void writeOutput(String directory) throws IOException {
File f = new File(directory);
int i = 0;
if (f.isDirectory()) {
for (AppInventorScreen screen : screens.values()) {
File screenFile = new File(getScreenFilePath(f.getAbsolutePath(), screen));
... | true |
1,131 | 11,507,466 | 11,088,622 | public PollSetMessage(String username, String question, String title, String[] choices) {
this.username = username;
MessageDigest m = null;
try {
m = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
... | public static void copyFile(File sourceFile, File destFile) throws IOException {
InputStream is = null;
OutputStream os = null;
try {
is = new FileInputStream(sourceFile);
os = new FileOutputStream(destFile);
IOUtils.copy(is, os);
} finally {
... | false |
1,132 | 12,915,753 | 13,521,323 | private String readDataFromUrl(URL url) throws IOException {
InputStream inputStream = null;
InputStreamReader streamReader = null;
BufferedReader in = null;
StringBuffer data = new StringBuffer();
try {
inputStream = url.openStream();
streamReader = n... | public static void copyFile(final String inFile, final String outFile) {
FileChannel in = null;
FileChannel out = null;
try {
in = new FileInputStream(inFile).getChannel();
out = new FileOutputStream(outFile).getChannel();
in.transferTo(0, in.size(), out);... | false |
1,133 | 1,655,162 | 520,600 | public boolean updatenum(int num, String pid) {
boolean flag = false;
Connection conn = null;
PreparedStatement pm = null;
try {
conn = Pool.getConnection();
conn.setAutoCommit(false);
pm = conn.prepareStatement("update addwuliao set innum=? where ... | 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... | false |
1,134 | 4,207,693 | 20,539,816 | private synchronized boolean saveU(URL url, String typeFlag, byte[] arrByte) {
BufferedReader buffReader = null;
BufferedOutputStream buffOS = null;
URLConnection urlconnection = null;
char flagChar = '0';
boolean flag = true;
try {
urlconnection = url.ope... | public static Collection<SearchKeyResult> searchKey(String iText, String iKeyServer) throws Exception {
Vector<SearchKeyResult> outVec = new Vector<SearchKeyResult>();
String uri = iKeyServer + "/pks/lookup?search=" + URLEncoder.encode(iText, "UTF-8");
URL url = new URL(uri);
Buffere... | false |
1,135 | 4,130,551 | 10,182,360 | private byte[] streamToBytes(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
IOUtils.copy(in, out);
} finally {
IOUtils.closeQuietly(in);
}
return out.toByteArray();
}
| public void getDownloadInfo(String _url) throws Exception {
cl = new FTPClient();
Authentication auth = new FTPAuthentication();
cl.connect(getHostName());
while (!cl.login(auth.getUser(), auth.getPassword())) {
log.debug("getDownloadInfo() - login error state: " + Arrays... | false |
1,136 | 4,843,969 | 2,791,310 | public void buildCache() {
CacheManager.resetCache();
XMLCacheBuilder cacheBuilder = CompositePageUtil.getCacheBuilder();
if (cacheBuilder == null) return;
String pathStr = cacheBuilder.getPath();
if (pathStr == null) return;
String[] paths = pathStr.split("\n");
... | protected synchronized AbstractBaseObject insert(AbstractBaseObject obj) throws ApplicationException {
PreparedStatement preStat = null;
StringBuffer sqlStat = new StringBuffer();
DmsRelationalWord tmpDmsRelationalWord = (DmsRelationalWord) ((DmsRelationalWord) obj).clone();
synchron... | false |
1,137 | 1,833,576 | 7,300,247 | public FTPClient getFTP(final Credentials credentials, final String remoteFile) throws NumberFormatException, SocketException, IOException, AccessDeniedException {
String fileName = extractFilename(remoteFile);
String fileDirectory = getPathName(remoteFile).substring(0, getPathName(remoteFile).index... | 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,138 | 22,305,828 | 21,956,399 | protected InputSource getInputSource(String pReferencingSystemId, String pURI) throws SAXException {
URL url = null;
if (pReferencingSystemId != null) {
try {
url = new URL(new URL(pReferencingSystemId), pURI);
} catch (MalformedURLException e) {
}... | @Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("application/json");
resp.setCharacterEncoding("utf-8");
String format = req.getParameter("format");
EntityManager em = EMF.get().createEntityManager();
... | false |
1,139 | 20,544,327 | 820,905 | public static void copyFile(File fileIn, File fileOut) throws IOException {
FileChannel chIn = new FileInputStream(fileIn).getChannel();
FileChannel chOut = new FileOutputStream(fileOut).getChannel();
try {
chIn.transferTo(0, chIn.size(), chOut);
} catch (IOException e) {... | 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,140 | 10,174,628 | 978,946 | @Override
public T[] sort(T[] values) {
super.compareTimes = 0;
for (int i = 0; i < values.length; i++) {
for (int j = 0; j < values.length - i - 1; j++) {
super.compareTimes++;
if (values[j].compareTo(values[j + 1]) > 0) {
T temp =... | public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} catch (IOExcep... | false |
1,141 | 9,324,781 | 708,047 | public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException {
String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
if (name != null && wanted.containsKey(name)) {
FileOutputStream out = new File... | public static void main(String args[]) {
try {
URL url = new URL("http://www.hungry.com/");
InputStream stream = url.openStream();
int size = 0;
while (-1 != stream.read()) {
size++;
}
stream.close();
System.... | false |
1,142 | 14,196,272 | 10,555,214 | private synchronized File gzipTempFile(File tempFile) throws BlogunityException {
try {
File gzippedFile = new File(BlogunityManager.getSystemConfiguration().getTempDir(), tempFile.getName() + ".gz");
GZIPOutputStream zos = new GZIPOutputStream(new FileOutputStream(gzippedFile));
... | public static Test suite() throws Exception {
java.net.URL url = ClassLoader.getSystemResource("host0.jndi.properties");
java.util.Properties host0JndiProps = new java.util.Properties();
host0JndiProps.load(url.openStream());
java.util.Properties systemProps = System.getProperties();... | false |
1,143 | 16,226,357 | 23,531,658 | private String getHash(String string) {
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
md5.reset();
md5.update(string.getBytes());
byte[] result = md... | public void objectParserAssesmentItem(int file, int currentquestion, Resource resTemp) {
NodeList nl = null;
Node n = null;
NamedNodeMap nnp = null;
Node nsrc = null;
URL url = null;
String sFilename = "";
String sNewPath = "";
int indexLastSeparator;
... | false |
1,144 | 20,924,120 | 3,070,691 | public static void gunzip() throws Exception {
System.out.println("gunzip()");
GZIPInputStream zipin = new GZIPInputStream(new FileInputStream("/zip/myzip.gz"));
byte buffer[] = new byte[BLOCKSIZE];
FileOutputStream out = new FileOutputStream("/zip/covers");
for (int length; ... | public void lookupAllFactories() throws IOException {
Enumeration setOfFactories = null;
ClassLoader classLoader = null;
InputStream inputStream = null;
classLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
... | false |
1,145 | 1,362,131 | 23,022,777 | public void moveRowDown(int row) throws FidoDatabaseException {
try {
Connection conn = null;
Statement stmt = null;
try {
conn = fido.util.FidoDataSource.getConnection();
conn.setAutoCommit(false);
stmt = conn.createStateme... | public void processSaveHolding(Holding holdingBean, AuthSession authSession) {
if (authSession == null) {
return;
}
DatabaseAdapter dbDyn = null;
PreparedStatement ps = null;
try {
dbDyn = DatabaseAdapter.getInstance();
String sql = "UPDATE... | true |
1,146 | 19,235,547 | 22,079,999 | protected BufferedImage handleRaremapsException() {
if (params.uri.startsWith("http://www.raremaps.com/cgi-bin/gallery.pl/detail/")) try {
params.uri = params.uri.replace("cgi-bin/gallery.pl/detail", "maps/medium");
URL url = new URL(params.uri);
URLConnection connection ... | public static SubstanceSkin.ColorSchemes getColorSchemes(URL url) {
List<SubstanceColorScheme> schemes = new ArrayList<SubstanceColorScheme>();
BufferedReader reader = null;
Color ultraLight = null;
Color extraLight = null;
Color light = null;
Color mid = null;
... | false |
1,147 | 2,247,987 | 3,791,822 | public static void main(String argv[]) {
Matrix A, B, C, Z, O, I, R, S, X, SUB, M, T, SQ, DEF, SOL;
int errorCount = 0;
int warningCount = 0;
double tmp, s;
double[] columnwise = { 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12. };
double[] rowwise = { 1., 4., 7., 1... | public Void doInBackground() {
setProgress(0);
for (int i = 0; i < uploadFiles.size(); i++) {
String filePath = uploadFiles.elementAt(i).getFilePath();
String fileName = uploadFiles.elementAt(i).getFileName();
String fileMsg = "Uploading fi... | true |
1,148 | 8,085,496 | 3,024,981 | public MemoryBinaryBody(InputStream is) throws IOException {
TempPath tempPath = TempStorage.getInstance().getRootTempPath();
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(is, out);
out.close();
tempFile = out.toByteArray();
}
| @Test
public void testCopy_inputStreamToWriter_Encoding_nullIn() throws Exception {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
OutputStream out = new YellOnFlushAndCloseOutputStreamTest(baout, true, true);
Writer writer = new OutputStreamWriter(baout, "US-ASCII");
... | true |
1,149 | 16,704,464 | 5,859,989 | public static void main(String[] args) {
File directory = new File(args[0]);
File[] files = directory.listFiles();
try {
PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(args[1])));
for (int i = 0; i < files.length; i++) {
Buffere... | public Integer execute(Connection con) throws SQLException {
int updateCount = 0;
boolean oldAutoCommitSetting = con.getAutoCommit();
Statement stmt = null;
try {
con.setAutoCommit(autoCommit);
stmt = con... | false |
1,150 | 952,021 | 854,534 | public static void doVersionCheck(View view) {
view.showWaitCursor();
try {
URL url = new URL(jEdit.getProperty("version-check.url"));
InputStream in = url.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
String line;
... | public static void doVersionCheck(View view) {
view.showWaitCursor();
try {
URL url = new URL(jEdit.getProperty("version-check.url"));
InputStream in = url.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
String line;
... | true |
1,151 | 21,722,036 | 22,010,538 | public void loadXML(URL flux, int status, File file) {
try {
SAXBuilder sbx = new SAXBuilder();
try {
if (file.exists()) {
file.delete();
}
if (!file.exists()) {
URLConnection conn = flux.openConn... | private byte[] getBytes(String resource) throws IOException {
InputStream is = HttpServletFileDownloadTest.class.getResourceAsStream(resource);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(is, out);
IOUtils.closeQuietly(is);
return out.toByteArray();
... | true |
1,152 | 421,187 | 20,696,811 | private void displayDiffResults() throws IOException {
File outFile = File.createTempFile("diff", ".htm");
outFile.deleteOnExit();
FileOutputStream outStream = new FileOutputStream(outFile);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream));
out.write... | private static boolean insereTutorial(final Connection con, final Tutorial tut, final Autor aut, final Descricao desc) {
try {
con.setAutoCommit(false);
Statement smt = con.createStatement();
if (aut.getCodAutor() == 0) {
GeraID.gerarCodAutor(con, aut);
... | false |
1,153 | 11,946,782 | 11,305,839 | public static void addIntegrityEnforcements(Session session) throws HibernateException {
Transaction tx = null;
try {
tx = session.beginTransaction();
Statement st = session.connection().createStatement();
st.executeUpdate("DROP TABLE hresperformsrole;" + "CREATE ... | public boolean setCliente(int IDcliente, String nombre, String paterno, String materno, String ocupacion, String rfc) {
boolean inserto = false;
try {
stm = conexion.prepareStatement("insert into clientes values( '" + IDcliente + "' , '" + nombre.toUpperCase() + "' , '" + paterno.toUpper... | true |
1,154 | 2,114,072 | 8,156,588 | public String readFile(String filename) throws IOException {
FTPClient ftpClient = new FTPClient();
ftpClient.connect(server, port);
ftpClient.login(USERNAME, PASSWORD);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
boolean success = ftpClient.retrieveFile... | private static final BufferedInputStream createInputStreamFromRemoteUrl(String uri, ClientConnectionManager connectionManager) {
InputStream contentInput = null;
if (connectionManager == null) {
try {
URL url = new URI(uri).toURL();
URLConnection conn = ur... | false |
1,155 | 17,907,353 | 3,647,667 | public static void resourceToFile(final String resource, final String filePath) throws IOException {
log.debug("Classloader is " + IOCopyUtils.class.getClassLoader());
InputStream in = IOCopyUtils.class.getResourceAsStream(resource);
if (in == null) {
log.warn("Resource not '" + ... | public static String getMdPsw(String passwd) throws Exception {
MessageDigest md;
md = MessageDigest.getInstance("MD5");
byte[] md5hash = new byte[32];
md.update(passwd.getBytes("iso-8859-1"), 0, passwd.length());
md5hash = md.digest();
return convertToHex(md5hash);
... | false |
1,156 | 17,513,478 | 9,186,576 | public void create(File target) {
if ("dir".equals(type)) {
File dir = new File(target, name);
dir.mkdirs();
for (Resource c : children) {
c.create(dir);
}
} else if ("package".equals(type)) {
String[] dirs = name.split("\\.... | public static void copyFile(File file, String pathExport) throws IOException {
File out = new File(pathExport);
FileChannel sourceChannel = new FileInputStream(file).getChannel();
FileChannel destinationChannel = new FileOutputStream(out).getChannel();
sourceChannel.transferTo(0, sou... | true |
1,157 | 7,119,938 | 11,050,195 | 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... | private void writeFile(File file, String fileName) {
try {
FileInputStream fin = new FileInputStream(file);
FileOutputStream fout = new FileOutputStream(dirTableModel.getDirectory().getAbsolutePath() + File.separator + fileName);
int val;
while ((val = fin.rea... | true |
1,158 | 13,247,161 | 16,050,015 | private void findFile() throws SchedulerException {
java.io.InputStream f = null;
String furl = null;
File file = new File(getFileName());
if (!file.exists()) {
URL url = classLoadHelper.getResource(getFileName());
if (url != null) {
try {
... | public static void downloadFile(String htmlUrl, String dirUrl) {
try {
URL url = new URL(htmlUrl);
System.out.println("Opening connection to " + htmlUrl + "...");
URLConnection urlC = url.openConnection();
InputStream is = url.openStream();
Date da... | false |
1,159 | 11,825,739 | 6,790,585 | public static void copyFile(String from, String to, boolean append) throws IOException {
FileChannel in = new FileInputStream(from).getChannel();
FileChannel out = new FileOutputStream(to, append).getChannel();
ByteBuffer buffer = ByteBuffer.allocate(BSIZE);
while (in.read(buffer) !=... | private void sendToServer(String fichaID, String respostas) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException, URISyntaxException {
ArrayList params = new ArrayList();
params.add(new BasicNameValuePair("xml", respostas));
params.add(new BasicNameValuePair(... | false |
1,160 | 22,807,014 | 6,184,983 | @Test
public void test() throws JDOMException, IOException {
InputStream is = this.getClass().getResourceAsStream("putRegularVehicle.xml");
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
IOUtils.copy(is, byteArrayOutputStream);
TrafficModelDefinition d... | @Override
public boolean copyFile(String srcRootPath, String srcDir, String srcFileName, String destRootPath, String destDir, String destFileName) {
File srcPath = new File(srcRootPath + separator() + Database.getDomainName() + separator() + srcDir);
if (!srcPath.exists()) {
try {
... | true |
1,161 | 12,465,375 | 935,017 | private void write(File src, File dst, byte id3v1Tag[], byte id3v2HeadTag[], byte id3v2TailTag[]) throws IOException {
if (src == null || !src.exists()) throw new IOException(Debug.getDebug("missing src", src));
if (!src.getName().toLowerCase().endsWith(".mp3")) throw new IOException(Debug.getDebug(... | 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 |
1,162 | 17,253,878 | 40,044 | 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()");
}
... | 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,163 | 16,700,020 | 820,872 | public static byte[] computeMD5(String s) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.reset();
md.update(s.getBytes());
return md.digest();
} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException(ex);
... | 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... | false |
1,164 | 13,490,964 | 23,596,949 | public void write(File file) throws Exception {
if (isInMemory()) {
FileOutputStream fout = null;
try {
fout = new FileOutputStream(file);
fout.write(get());
} finally {
if (fout != null) {
fout.close();
... | public static void copyFile(File source, File dest) throws IOException {
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
MappedByteBuffer buf ... | true |
1,165 | 272,875 | 716,032 | 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 getZipFiles(String filename) {
try {
String destinationname = "c:\\mods\\peu\\";
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(filename));
... | true |
1,166 | 18,047,482 | 5,433,054 | @Transactional(readOnly = false)
public void saveOrUpdateProduct(Product product, File[] doc, String[] docFileName, String[] docContentType) throws IOException {
logger.info("addOrUpdateProduct()");
List<Images> imgList = new ArrayList<Images>();
InputStream in = null;
OutputStre... | public static String getRefCatastral(String pURL) {
String result = new String();
String iniPC1 = "<pc1>";
String iniPC2 = "<pc2>";
String finPC1 = "</pc1>";
String finPC2 = "</pc2>";
String iniCuerr = "<cuerr>";
String finCuerr = "</cuerr>";
String in... | false |
1,167 | 3,287,281 | 11,404,999 | private void googleImageSearch() {
bottomShowing = true;
googleSearched = true;
googleImageLocation = 0;
googleImages = new Vector<String>();
custom = "";
int r = JOptionPane.showConfirmDialog(this, "Customize google search?", "Google Search", JOptionPane.YES_NO_OPTIO... | public boolean moveFileSafely(final File in, final File out) throws IOException {
FileInputStream fis = null;
FileOutputStream fos = null;
FileChannel inChannel = null;
FileChannel outChannel = null;
final File tempOut = File.createTempFile("move", ".tmp");
try {
... | false |
1,168 | 8,181,418 | 9,210,167 | public static final byte[] getBytesFromUrl(final String urlString) throws BT747Exception {
byte[] result = null;
try {
final URL url = new URL(urlString);
final URLConnection urlc = url.openConnection();
urlc.setConnectTimeout(timeout);
urlc.setReadTim... | void updateSource(Class<?> type) throws Exception {
final String path = type.getName().replaceAll("\\.", "/") + ".java";
new Thread(new Runnable() {
@Override
public void run() {
try {
URL url = Thread.currentThread().getContextClassLoader... | true |
1,169 | 10,425,169 | 4,981,909 | private void getRandomGUID(boolean secure, Object o) {
MessageDigest md5 = null;
StringBuffer sbValueBeforeMD5 = new StringBuffer();
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
System.out.println("Error: " + e);
... | public static File enregistrerFichier(String fileName, File file, String path, String fileMime) throws Exception {
if (file != null) {
try {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
... | false |
1,170 | 22,717,685 | 3,024,977 | public static final void copy(File src, File dest) throws IOException {
FileInputStream source = null;
FileOutputStream destination = null;
byte[] buffer;
int bytes_read;
if (!src.exists()) {
throw new IOException("Source not found: " + src);
}
if ... | @Test
public void testCopy_inputStreamToWriter() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStreamTest(in);
ByteArrayOutputStream baout = new ByteArrayOutputStream();
YellOnFlushAndCloseOutputStreamTest out = new YellOnFlushAndC... | true |
1,171 | 18,956,017 | 23,004,478 | public void writeFile(OutputStream outputStream) throws IOException {
InputStream inputStream = null;
if (file != null) {
try {
inputStream = new FileInputStream(file);
IOUtils.copy(inputStream, outputStream);
} fina... | @Override
public int onPut(Operation operation) {
synchronized (MuleObexRequestHandler.connections) {
MuleObexRequestHandler.connections++;
if (logger.isDebugEnabled()) {
logger.debug("Connection accepted, total number of connections: " + MuleObexRequestHandler.co... | true |
1,172 | 20,059,162 | 11,779,245 | public boolean excuteBackup(String backupOrginlDrctry, String targetFileNm, String archiveFormat) throws JobExecutionException {
File targetFile = new File(targetFileNm);
File srcFile = new File(backupOrginlDrctry);
if (!srcFile.exists()) {
log.error("백업원본디렉토리[" + srcFile.getAbso... | @SuppressWarnings("unchecked")
public static void zip(String input, OutputStream out) {
File file = new File(input);
ZipOutputStream zip = null;
FileInputStream in = null;
try {
if (file.exists()) {
Collection<File> items = new ArrayList();
... | true |
1,173 | 14,132,423 | 7,315,828 | public static void bubble_sort(int[] objects, int len) {
for (int i = len; --i >= 0; ) {
boolean flipped = false;
for (int j = 0; j < i; j++) {
if (objects[j + 1] < objects[j]) {
int tmp = objects[j];
objects[j] = objects[j + 1]... | private void copyOutResource(String dstPath, InputStream in) throws FileNotFoundException, IOException {
FileOutputStream out = null;
try {
dstPath = this.outputDir + dstPath;
File file = new File(dstPath);
file.getParentFile().mkdirs();
out = new File... | false |
1,174 | 12,829,112 | 330,896 | public String getDigest(String algorithm, String data) throws IOException, NoSuchAlgorithmException {
MessageDigest md = java.security.MessageDigest.getInstance(algorithm);
md.reset();
md.update(data.getBytes());
return md.digest().toString();
}
| 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) {
... | false |
1,175 | 16,654,272 | 20,898,459 | public AudioInputStream getAudioInputStream(URL url, String userAgent) throws UnsupportedAudioFileException, IOException {
if (TDebug.TraceAudioFileReader) {
TDebug.out("MpegAudioFileReaderWorkaround.getAudioInputStream(URL,String): begin");
}
long lFileLengthInBytes = AudioSyste... | 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(... | false |
1,176 | 16,351,775 | 17,965,575 | 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.... | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
OutputStream output = getOutputStream();
if (cachedContent != null) {
output.write(cachedContent);
} else {
FileInputStream input = new FileInput... | true |
1,177 | 14,865,741 | 18,785,060 | public boolean login(URL strUrl, String loginName, String loginPwd, String sessionID) throws Exception {
String starter = "-----------------------------";
String returnChar = "\r\n";
String lineEnd = "--";
URL urlString = strUrl;
String input = null;
List txtList = ne... | public static NotaFiscal insert(NotaFiscal objNF) {
final Connection c = DBConnection.getConnection();
PreparedStatement pst = null;
int result;
if (c == null) {
return null;
}
if (objNF == null) {
return null;
}
try {
... | false |
1,178 | 8,868,054 | 1,342,927 | private String getCurrentUniprotAccession(String accession) throws Exception {
URL url = new URL(String.format(UNIPROT_ENTRY_QUERY_STRING, accession));
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
HttpURLConnection.setFollowRedirects(true);
connection.setR... | public static InputStream getResourceAsStream(String resourceName) {
try {
URL url = getEmbeddedFileUrl(WS_SEP + resourceName);
if (url != null) {
return url.openStream();
}
} catch (MalformedURLException e) {
GdtAndroidPlugin.getLogger... | false |
1,179 | 211,061 | 3,472,611 | private void displayDiffResults() throws IOException {
File outFile = File.createTempFile("diff", ".htm");
outFile.deleteOnExit();
FileOutputStream outStream = new FileOutputStream(outFile);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream));
out.write... | @Override
public void onClick(View view) {
String ftpHostname = getFtpHostname();
String ftpUsername = getFtpUsername();
String ftpPassword = getFtpPassword();
int ftpPort = getFtpPort();
String dialogText = getString(R.string.testingFTPConnectionDialogHeaderText) + " " +... | false |
1,180 | 4,209,926 | 16,619,660 | public static void proxyRequest(IPageContext context, Writer writer, String proxyPath) throws IOException {
URLConnection connection = new URL(proxyPath).openConnection();
connection.setDoInput(true);
connection.setDoOutput(false);
connection.setUseCaches(false);
connection.s... | public PropertiesImpl(URL url) {
this();
InputStream in = null;
lock.lock();
try {
in = url.openStream();
PropertiesLexer lexer = new PropertiesLexer(in);
lexer.lex();
List<PropertiesToken> list = lexer.getList();
new Proper... | false |
1,181 | 15,561,074 | 18,138,572 | private void httpDo(HttpUriRequest hr, String url, Map<String, String> headers, AjaxStatus status) throws ClientProtocolException, IOException {
if (AGENT != null) {
hr.addHeader("User-Agent", AGENT);
}
if (headers != null) {
for (String name : headers.keySet()) {
... | 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 |
1,182 | 19,870,772 | 17,907,353 | @RequestMapping(value = "/verdocumentoFisico.html", method = RequestMethod.GET)
public String editFile(ModelMap model, @RequestParam("id") int idAnexo) {
Anexo anexo = anexoService.selectById(idAnexo);
model.addAttribute("path", anexo.getAnexoCaminho());
try {
InputStream is ... | public static void resourceToFile(final String resource, final String filePath) throws IOException {
log.debug("Classloader is " + IOCopyUtils.class.getClassLoader());
InputStream in = IOCopyUtils.class.getResourceAsStream(resource);
if (in == null) {
log.warn("Resource not '" + ... | true |
1,183 | 6,214,331 | 12,226,563 | public static void copyFile(File src, File dest) {
try {
FileInputStream in = new FileInputStream(src);
FileOutputStream out = new FileOutputStream(dest);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
out.close();
... | public void run() {
Vector<Update> updates = new Vector<Update>();
if (dic != null) updates.add(dic);
if (gen != null) updates.add(gen);
if (res != null) updates.add(res);
if (help != null) updates.add(help);
for (Iterator iterator = updates.iterator(); iterator.hasNe... | true |
1,184 | 9,106,128 | 7,066,835 | protected long getUrlSize(String location) {
long returnValue = 0L;
try {
URL url = new URL(location);
java.net.HttpURLConnection conn = (java.net.HttpURLConnection) url.openConnection();
conn.setRequestMethod("HEAD");
returnValue = conn.getContentLeng... | protected List<Datastream> getDatastreams(final DepositCollection pDeposit) throws IOException, SWORDException {
List<Datastream> tDatastreams = new ArrayList<Datastream>();
LOG.debug("copying file");
String tZipTempFileName = super.getTempDir() + "uploaded-file.tmp";
IOUtils.copy(pD... | false |
1,185 | 4,525,216 | 716,032 | private static void backupFile(File file) {
FileChannel in = null, out = null;
try {
if (!file.getName().endsWith(".bak")) {
in = new FileInputStream(file).getChannel();
out = new FileOutputStream(new File(file.toString() + ".bak")).getChannel();
... | public void getZipFiles(String filename) {
try {
String destinationname = "c:\\mods\\peu\\";
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(filename));
... | true |
1,186 | 14,803,891 | 6,291,471 | public File sendPayload(SoapEnvelope payload, URL url) throws IOException {
URLConnection conn = null;
File tempFile = null;
Logger l = Logger.instance();
String className = getClass().getName();
l.log(Logger.DEBUG, loggerPrefix, className + ".sendPayload", "sending payload t... | private void copyFile(File f) throws IOException {
File newFile = new File(destdir + "/" + f.getName());
newFile.createNewFile();
FileInputStream fin = new FileInputStream(f);
FileOutputStream fout = new FileOutputStream(newFile);
int c;
while ((c = fin.read()) != -1)... | false |
1,187 | 11,875,445 | 18,385,066 | private static void loadFromZip() {
InputStream in = Resources.class.getResourceAsStream("data.zip");
if (in == null) {
return;
}
ZipInputStream zipIn = new ZipInputStream(in);
try {
while (true) {
ZipEntry entry = zipIn.getNextEntry();... | 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 |
1,188 | 9,558,449 | 21,348,949 | public int openUrl(String url, String method, Bundle params) {
int result = 0;
try {
if (method.equals("GET")) {
url = url + "?" + Utility.encodeUrl(params);
}
String response = "";
HttpURLConnection conn = (HttpURLConnection) new URL(u... | protected void onSubmit() {
super.onSubmit();
if (!this.hasError()) {
final FileUpload upload = fileUploadField.getFileUpload();
if (upload != null) {
try {
StringWriter xmlSourceWriter = new StringWriter();
... | false |
1,189 | 23,594,635 | 6,190,168 | 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 void xtest12() throws Exception {
PDFManager manager = new ITextManager();
InputStream pdf = new FileInputStream("/tmp/090237098008f637.pdf");
InputStream page1 = manager.cut(pdf, 36, 36);
OutputStream outputStream = new FileOutputStream("/tmp/090237098008f637-1.pdf");
... | true |
1,190 | 19,722,336 | 7,005,223 | @Override
public String entryToObject(TupleInput input) {
boolean zipped = input.readBoolean();
if (!zipped) {
return input.readString();
}
int len = input.readInt();
try {
byte array[] = new byte[len];
... | public void checkFilesAndCopyValid(String filename) {
downloadResults();
loadResults();
File tmpFolderF = new File(tmpFolder);
deleteFileFromTMPFolder(tmpFolderF);
ZipReader zr = new ZipReader();
zr.UnzipFile(filename);
try {
LogManager.getInstance... | true |
1,191 | 14,257,554 | 21,959,565 | @Override
public synchronized File download_dictionary(Dictionary dict, String localfpath) {
abort = false;
try {
URL dictionary_location = new URL(dict.getLocation());
InputStream in = dictionary_location.openStream();
FileOutputStream w = new FileOutputStrea... | public Font(String path, String fontName) {
this();
StringTokenizer tok = new StringTokenizer(path, ";");
NybbleInputStream str = null;
while (str == null & tok.hasMoreTokens()) {
try {
URL url = new URL(tok.nextToken() + "/");
url = new UR... | false |
1,192 | 80,378 | 9,077,865 | public static void test(String args[]) {
int trace;
int bytes_read = 0;
int last_contentLenght = 0;
try {
BufferedReader reader;
URL url;
url = new URL(args[0]);
URLConnection istream = url.openConnection();
last_contentLeng... | @Override
public void exec() {
if (fileURI == null) return;
InputStream is = null;
try {
if (fileURI.toLowerCase().startsWith("dbgp://")) {
String uri = fileURI.substring(7);
if (uri.toLowerCase().startsWith("file/")) {
uri ... | false |
1,193 | 4,643,706 | 16,993,715 | private static void zip(ZipOutputStream aOutputStream, final File[] aFiles, final String sArchive, final URI aRootURI, final String sFilter) throws FileError {
boolean closeStream = false;
if (aOutputStream == null) try {
aOutputStream = new ZipOutputStream(new FileOutputStream(sArchive)... | public static boolean copyFile(String fromfile, String tofile) {
File from = new File(fromfile);
File to = new File(tofile);
if (!from.exists()) return false;
if (to.exists()) {
log.error(tofile + "exists already");
return false;
}
BufferedInpu... | true |
1,194 | 12,670,642 | 20,654,481 | public boolean backupLastAuditSchema(File lastAuditSchema) {
boolean isBkupFileOK = false;
String writeTimestamp = DateFormatUtils.format(new java.util.Date(), configFile.getTimestampPattern());
File target = new File(configFile.getAuditSchemaFileDir() + File.separator + configFile.getAuditS... | private ParserFileReader createParserFileReader(final FromNetRecord record) throws IOException {
final String strUrl = record.getStrUrl();
ParserFileReader parserFileReader;
try {
parserFileReader = parserFileReaderFactory.create(strUrl);
} catch (Exception exception) {
... | true |
1,195 | 7,847,873 | 22,608,285 | public String decrypt(String text, String passphrase, int keylen) {
RC2ParameterSpec parm = new RC2ParameterSpec(keylen);
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
md.update(passphrase.getBytes(getCharset()));
SecretKeySpec skeySpec = ... | private void dealWith(String line) throws Exception {
if (line.startsWith("#") || (line.length() == 0)) {
return;
}
String sarr[];
sarr = StringUtil.split(line, '\t');
String path = destDir + File.separator + sarr[0];
boolean copyFile = true;
if (s... | false |
1,196 | 16,687,411 | 16,083,957 | private ByteBuffer readProgram(URL url) throws IOException {
StringBuilder program = new StringBuilder();
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = in.readLine()) != null) ... | 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... | false |
1,197 | 22,207,784 | 7,507,773 | 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 {
... | public boolean restore(File directory) {
log.debug("restore file from directory " + directory.getAbsolutePath());
try {
if (!directory.exists()) return false;
String[] operationFileNames = directory.list();
if (operationFileNames.length < 6) {
log.... | true |
1,198 | 11,572,565 | 5,011,665 | public static final boolean copy(File source, File target, boolean overwrite) {
if (!overwrite && target.exists()) {
LOGGER.error("Target file exist and it not permitted to overwrite it !");
return false;
}
FileChannel in = null;
FileChannel out = null;
... | public void upgradeSingleFileModelToDirectory(File modelFile) throws IOException {
byte[] buf = new byte[8192];
int bytesRead = 0;
File backupModelFile = new File(modelFile.getPath() + ".bak");
FileInputStream oldModelIn = new FileInputStream(modelFile);
FileOutputStream back... | true |
1,199 | 20,580,825 | 3,308,516 | public static ByteBuffer readURL(URL url) throws IOException, MalformedURLException {
URLConnection connection = null;
try {
connection = url.openConnection();
return readInputStream(new BufferedInputStream(connection.getInputStream()));
} catch (IOException e) {
... | public String[] doGeoQuery(String query) throws IOException {
String baseURL = "http://maps.google.com/maps/geo?output=csv&keyABQIAAAAct2NN7QKbyiMr1rfhB6UGBQn1DChMmG6tCCZd3aXbcL03vlL5hSUZpyoaGCXRwjbRTSBi0L89DeYeg&q=";
URL url = new URL(baseURL + URLEncoder.encode(query, "UTF-8"));
URLConnect... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.