List of usage examples for org.apache.commons.net.ftp FTP BINARY_FILE_TYPE
int BINARY_FILE_TYPE
To view the source code for org.apache.commons.net.ftp FTP BINARY_FILE_TYPE.
Click Source Link
From source file:com.cladonia.xngreditor.URLUtilities.java
public static void save(URL url, InputStream input, String encoding) throws IOException { // System.out.println( "URLUtilities.save( "+url+", "+encoding+")"); String password = URLUtilities.getPassword(url); String username = URLUtilities.getUsername(url); String protocol = url.getProtocol(); if (protocol.equals("ftp")) { FTPClient client = null;// w ww . j a va 2 s . c om String host = url.getHost(); client = new FTPClient(); // System.out.println( "Connecting ..."); client.connect(host); // System.out.println( "Connected."); // After connection attempt, you should check the reply code to verify // success. int reply = client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { // System.out.println( "Disconnecting..."); client.disconnect(); throw new IOException("FTP Server \"" + host + "\" refused connection."); } // System.out.println( "Logging in ..."); if (!client.login(username, password)) { // System.out.println( "Could not log in."); // TODO bring up login dialog? client.disconnect(); throw new IOException("Could not login to FTP Server \"" + host + "\"."); } // System.out.println( "Logged in."); client.setFileType(FTP.BINARY_FILE_TYPE); client.enterLocalPassiveMode(); // System.out.println( "Writing output ..."); OutputStream output = client.storeFileStream(url.getFile()); // if( !FTPReply.isPositiveIntermediate( client.getReplyCode())) { // output.close(); // client.disconnect(); // throw new IOException( "Could not transfer file \""+url.getFile()+"\"."); // } InputStreamReader reader = new InputStreamReader(input, encoding); OutputStreamWriter writer = new OutputStreamWriter(output, encoding); int ch = reader.read(); while (ch != -1) { writer.write(ch); ch = reader.read(); } writer.flush(); writer.close(); output.close(); // Must call completePendingCommand() to finish command. if (!client.completePendingCommand()) { client.disconnect(); throw new IOException("Could not transfer file \"" + url.getFile() + "\"."); } else { client.disconnect(); } } else if (protocol.equals("http") || protocol.equals("https")) { WebdavResource webdav = createWebdavResource(toString(url), username, password); if (webdav != null) { webdav.putMethod(url.getPath(), input); webdav.close(); } else { throw new IOException("Could not transfer file \"" + url.getFile() + "\"."); } } else if (protocol.equals("file")) { FileOutputStream stream = new FileOutputStream(toFile(url)); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, encoding)); InputStreamReader reader = new InputStreamReader(input, encoding); int ch = reader.read(); while (ch != -1) { writer.write(ch); ch = reader.read(); } writer.flush(); writer.close(); } else { throw new IOException("The \"" + protocol + "\" protocol is not supported."); } }
From source file:edu.jhu.cvrg.services.nodeDataService.DataStaging.java
/** performs the core functions of consolidatePrimaryAndDerivedData(), * Gets the listed files from the ftp server and puts them in a local directory * /*from www.j a v a 2 s . c o m*/ * @param subjectIds - Not actually used anymore. "^" separated list of subject IDs to download files for. * @param fileNames - "^" separated list of file name to fetch, full paths. * @param destinationDir - Temporary local directory that the files will be copied to so they can be zipped. * @param ftpClient - ftp client that is already logged in and ready to transfer files. */ private void getResultfromFTP(String subjectIds, String fileNames, String destinationDir, ApacheCommonsFtpWrapper ftpClient) { debugPrintln(" > getResultfromFTP(): Fetching files from FTP:" + fileNames); StringTokenizer fileTokenizer = new StringTokenizer(fileNames, "^"); String currentFile; while (fileTokenizer.hasMoreTokens()) { currentFile = fileTokenizer.nextToken(); // Determine the folder this file is in. String currentFolder = currentFile.substring(0, currentFile.lastIndexOf(sep)); try { File f = new File(destinationDir); // create destination directory f.mkdir(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); } catch (IOException e1) { e1.printStackTrace(); } try { debugPrintln(" > FTP Folder:" + currentFolder); ftpClient.changeWorkingDirectory(currentFolder); String[] s = ftpClient.listNames(currentFolder); debugPrintln(" > Copying " + s.length + " files via ftp into directory: " + destinationDir); for (int i = 0; i < s.length; i++) { debugPrintln(" > " + i + ") " + currentFile); ftpClient.downloadFile(s[i], destinationDir + sep + s[i].substring(s[i].lastIndexOf(sep) + 1)); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.maxl.java.aips2sqlite.AllDown.java
public void downZurRose() { String fl = ""; String fp = ""; String fs = ""; try {// w w w .ja v a 2 s. c o m FileInputStream access = new FileInputStream(Constants.DIR_ZURROSE + "/access.ami.csv"); BufferedReader br = new BufferedReader(new InputStreamReader(access, "UTF-8")); String line; while ((line = br.readLine()) != null) { // Semicolon is used as a separator String[] gln = line.split(";"); if (gln.length > 2) { if (gln[0].equals("P_ywesee")) { fl = gln[0]; fp = gln[1]; fs = gln[2]; } } } br.close(); } catch (Exception e) { e.printStackTrace(); } FTPClient ftp_client = new FTPClient(); try { ftp_client.connect(fs, 21); ftp_client.login(fl, fp); ftp_client.enterLocalPassiveMode(); ftp_client.setFileType(FTP.BINARY_FILE_TYPE); System.out.println("- Connected to server " + fs + "..."); String[] working_dir = { "ywesee out", "../ywesee in" }; for (int i = 0; i < working_dir.length; ++i) { // Set working directory ftp_client.changeWorkingDirectory(working_dir[i]); int reply = ftp_client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { ftp_client.disconnect(); System.err.println("FTP server refused connection."); return; } // Get list of filenames FTPFile[] ftpFiles = ftp_client.listFiles(); if (ftpFiles != null && ftpFiles.length > 0) { // ... then download all csv files for (FTPFile f : ftpFiles) { String remote_file = f.getName(); if (remote_file.endsWith("csv")) { String local_file = remote_file; if (remote_file.startsWith("Artikelstamm")) local_file = Constants.CSV_FILE_DISPO_ZR; OutputStream os = new FileOutputStream(Constants.DIR_ZURROSE + "/" + local_file); System.out.print("- Downloading " + remote_file + " from server " + fs + "... "); boolean done = ftp_client.retrieveFile(remote_file, os); if (done) System.out.println("success."); else System.out.println("error."); os.close(); } } } } } catch (IOException ex) { System.out.println("Error: " + ex.getMessage()); ex.printStackTrace(); } finally { try { if (ftp_client.isConnected()) { ftp_client.logout(); ftp_client.disconnect(); } } catch (IOException ex) { ex.printStackTrace(); } } }
From source file:fr.bmartel.speedtest.SpeedTestTask.java
/** * Start FTP upload./*from ww w . j ava 2 s . c o m*/ * * @param hostname ftp host * @param port ftp port * @param uri upload uri * @param fileSizeOctet file size in octet * @param user username * @param password password */ public void startFtpUpload(final String hostname, final int port, final String uri, final int fileSizeOctet, final String user, final String password) { mSpeedTestMode = SpeedTestMode.UPLOAD; mUploadFileSize = new BigDecimal(fileSizeOctet); mForceCloseSocket = false; mErrorDispatched = false; if (mWriteExecutorService == null || mWriteExecutorService.isShutdown()) { mWriteExecutorService = Executors.newSingleThreadExecutor(); } mWriteExecutorService.execute(new Runnable() { @Override public void run() { final FTPClient ftpClient = new FTPClient(); final RandomGen randomGen = new RandomGen(); RandomAccessFile uploadFile = null; try { ftpClient.connect(hostname, port); ftpClient.login(user, password); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); byte[] fileContent = new byte[] {}; if (mSocketInterface.getUploadStorageType() == UploadStorageType.RAM_STORAGE) { /* generate a file with size of fileSizeOctet octet */ fileContent = randomGen.generateRandomArray(fileSizeOctet); } else { uploadFile = randomGen.generateRandomFile(fileSizeOctet); uploadFile.seek(0); } mFtpOutputstream = ftpClient.storeFileStream(uri); if (mFtpOutputstream != null) { mUploadTempFileSize = 0; final int uploadChunkSize = mSocketInterface.getUploadChunkSize(); final int step = fileSizeOctet / uploadChunkSize; final int remain = fileSizeOctet % uploadChunkSize; mTimeStart = System.currentTimeMillis(); mTimeEnd = 0; if (mRepeatWrapper.isFirstUpload()) { mRepeatWrapper.setFirstUploadRepeat(false); mRepeatWrapper.setStartDate(mTimeStart); } if (mRepeatWrapper.isRepeatUpload()) { mRepeatWrapper.updatePacketSize(mUploadFileSize); } if (mForceCloseSocket) { SpeedTestUtils.dispatchError(mForceCloseSocket, mListenerList, false, ""); } else { for (int i = 0; i < step; i++) { final byte[] chunk = SpeedTestUtils.readUploadData( mSocketInterface.getUploadStorageType(), fileContent, uploadFile, mUploadTempFileSize, uploadChunkSize); mFtpOutputstream.write(chunk, 0, uploadChunkSize); mUploadTempFileSize += uploadChunkSize; if (mRepeatWrapper.isRepeatUpload()) { mRepeatWrapper.updateTempPacketSize(uploadChunkSize); } if (!mReportInterval) { final SpeedTestReport report = mSocketInterface.getLiveUploadReport(); for (int j = 0; j < mListenerList.size(); j++) { mListenerList.get(j).onUploadProgress(report.getProgressPercent(), report); } } } if (remain != 0) { final byte[] chunk = SpeedTestUtils.readUploadData( mSocketInterface.getUploadStorageType(), fileContent, uploadFile, mUploadTempFileSize, remain); mFtpOutputstream.write(chunk, 0, remain); mUploadTempFileSize += remain; if (mRepeatWrapper.isRepeatUpload()) { mRepeatWrapper.updateTempPacketSize(remain); } } if (!mReportInterval) { final SpeedTestReport report = mSocketInterface.getLiveUploadReport(); for (int j = 0; j < mListenerList.size(); j++) { mListenerList.get(j).onUploadProgress(SpeedTestConst.PERCENT_MAX.floatValue(), report); } } mTimeEnd = System.currentTimeMillis(); } mFtpOutputstream.close(); mReportInterval = false; final SpeedTestReport report = mSocketInterface.getLiveUploadReport(); for (int i = 0; i < mListenerList.size(); i++) { mListenerList.get(i).onUploadFinished(report); } if (!mRepeatWrapper.isRepeatUpload()) { closeExecutors(); } } else { mReportInterval = false; SpeedTestUtils.dispatchError(mForceCloseSocket, mListenerList, false, "cant create stream " + "from uri " + uri + " with reply code : " + ftpClient.getReplyCode()); } } catch (SocketTimeoutException e) { //e.printStackTrace(); mReportInterval = false; mErrorDispatched = true; if (!mForceCloseSocket) { SpeedTestUtils.dispatchSocketTimeout(mForceCloseSocket, mListenerList, false, SpeedTestConst.SOCKET_WRITE_ERROR); } else { SpeedTestUtils.dispatchError(mForceCloseSocket, mListenerList, false, e.getMessage()); } closeSocket(); closeExecutors(); } catch (IOException e) { //e.printStackTrace(); mReportInterval = false; mErrorDispatched = true; SpeedTestUtils.dispatchError(mForceCloseSocket, mListenerList, false, e.getMessage()); closeExecutors(); } finally { mErrorDispatched = false; mSpeedTestMode = SpeedTestMode.NONE; disconnectFtp(ftpClient); if (uploadFile != null) { try { uploadFile.close(); randomGen.deleteFile(); } catch (IOException e) { //e.printStackTrace(); } } } } }); }
From source file:com.maxl.java.aips2sqlite.AllDown.java
public void downDesitin() { String fl = ""; String fp = ""; String fs = ""; try {//from ww w . jav a 2 s . co m FileInputStream access = new FileInputStream(Constants.DIR_DESITIN + "/access.ami.csv"); BufferedReader br = new BufferedReader(new InputStreamReader(access, "UTF-8")); String line; while ((line = br.readLine()) != null) { // Semicolon is used as a separator String[] gln = line.split(";"); if (gln.length > 2) { if (gln[0].equals("ftp_amiko")) { fl = gln[0]; fp = gln[1]; fs = gln[2]; } } } br.close(); } catch (Exception e) { e.printStackTrace(); } FTPClient ftp_client = new FTPClient(); try { ftp_client.connect(fs, 21); ftp_client.login(fl, fp); ftp_client.enterLocalPassiveMode(); ftp_client.setFileType(FTP.BINARY_FILE_TYPE); System.out.println("- Connected to server " + fs + "..."); // Set working directory String working_dir = "ywesee_in"; ftp_client.changeWorkingDirectory(working_dir); int reply = ftp_client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { ftp_client.disconnect(); System.err.println("FTP server refused connection."); return; } // Get list of filenames FTPFile[] ftpFiles = ftp_client.listFiles(); if (ftpFiles != null && ftpFiles.length > 0) { // ... then download all csv files for (FTPFile f : ftpFiles) { String remote_file = f.getName(); if (remote_file.endsWith("csv")) { String local_file = remote_file; if (remote_file.startsWith("Kunden")) local_file = Constants.FILE_CUST_DESITIN; if (remote_file.startsWith("Artikel")) local_file = Constants.FILE_ARTICLES_DESITIN; OutputStream os = new FileOutputStream(Constants.DIR_DESITIN + "/" + local_file); System.out.print("- Downloading " + remote_file + " from server " + fs + "... "); boolean done = ftp_client.retrieveFile(remote_file, os); if (done) System.out.println("success."); else System.out.println("error."); os.close(); } } } } catch (IOException ex) { System.out.println("Error: " + ex.getMessage()); ex.printStackTrace(); } finally { try { if (ftp_client.isConnected()) { ftp_client.logout(); ftp_client.disconnect(); } } catch (IOException ex) { ex.printStackTrace(); } } }
From source file:it.greenvulcano.util.remotefs.ftp.FTPManager.java
/** * @see it.greenvulcano.util.remotefs.RemoteManager#mv(String, String, * String, java.util.Map)/*from w ww .j ava2 s . co m*/ */ @Override public boolean mv(String remoteParentDirectory, String oldEntryName, String newEntryName, Map<String, String> optProperties) throws RemoteManagerException { checkConnected(); boolean result = false; try { if (remoteParentDirectory != null) { changeWorkingDirectory(remoteParentDirectory); } ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.rename(oldEntryName, newEntryName); int reply = ftpClient.getReplyCode(); if (FTPReply.isPositiveCompletion(reply)) { logger.debug("Remote entry " + oldEntryName + " renamed to " + newEntryName + "."); result = true; } else { logger.warn("FTP Server NEGATIVE response: "); logServerReply(Level.WARN); } return result; } catch (IOException exc) { throw new RemoteManagerException("I/O error", exc); } catch (Exception exc) { throw new RemoteManagerException("Generic error", exc); } finally { if (isAutoconnect()) { disconnect(); } } }
From source file:ch.cyberduck.core.ftp.FTPPath.java
@Override public InputStream read(final TransferStatus status) throws IOException { final FTPSession session = getSession(); this.data(new DataConnectionAction() { @Override//www . java 2s . co m public boolean run() throws IOException { if (!session.getClient().setFileType(FTP.BINARY_FILE_TYPE)) { throw new FTPException(session.getClient().getReplyString()); } return true; } }); if (status.isResume()) { // Where a server process supports RESTart in STREAM mode if (!session.getClient().isFeatureSupported("REST STREAM")) { status.setResume(false); } else { session.getClient().setRestartOffset(status.getCurrent()); } } return new ProxyInputStream(session.getClient().retrieveFileStream(getAbsolute())) { private boolean complete; @Override protected void afterRead(final int n) throws IOException { if (-1 == n) { complete = true; } } @Override public void close() throws IOException { try { super.close(); } finally { if (complete) { // Read 226 status if (!session.getClient().completePendingCommand()) { throw new FTPException(session.getClient().getReplyString()); } } else { // Interrupted transfer if (!session.getClient().abort()) { log.error("Error closing data socket:" + session.getClient().getReplyString()); } } } } }; }
From source file:com.microsoft.intellij.forms.CreateWebSiteForm.java
private void copyWebConfigForCustom(WebSiteConfiguration config) throws AzureCmdException { if (config != null) { AzureManager manager = AzureManagerImpl.getManager(project); WebSitePublishSettings webSitePublishSettings = manager.getWebSitePublishSettings( config.getSubscriptionId(), config.getWebSpaceName(), config.getWebSiteName()); // retrieve ftp publish profile WebSitePublishSettings.FTPPublishProfile ftpProfile = null; for (WebSitePublishSettings.PublishProfile pp : webSitePublishSettings.getPublishProfileList()) { if (pp instanceof WebSitePublishSettings.FTPPublishProfile) { ftpProfile = (WebSitePublishSettings.FTPPublishProfile) pp; break; }//from w w w .ja va 2s . com } if (ftpProfile != null) { FTPClient ftp = new FTPClient(); try { URI uri = null; uri = new URI(ftpProfile.getPublishUrl()); ftp.connect(uri.getHost()); final int replyCode = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(replyCode)) { ftp.disconnect(); } if (!ftp.login(ftpProfile.getUserName(), ftpProfile.getPassword())) { ftp.logout(); } ftp.setFileType(FTP.BINARY_FILE_TYPE); if (ftpProfile.isFtpPassiveMode()) { ftp.enterLocalPassiveMode(); } ftp.deleteFile(ftpPath + message("configName")); String tmpPath = String.format("%s%s%s", System.getProperty("java.io.tmpdir"), File.separator, message("configName")); File file = new File(tmpPath); if (file.exists()) { file.delete(); } WAEclipseHelperMethods.copyFile(WAHelper.getCustomJdkFile(message("configName")), tmpPath); String jdkFolderName = ""; if (customJDKUser.isSelected()) { String url = customUrl.getText(); jdkFolderName = url.substring(url.lastIndexOf("/") + 1, url.length()); jdkFolderName = jdkFolderName.substring(0, jdkFolderName.indexOf(".zip")); } else { String cloudVal = WindowsAzureProjectManager .getCloudValue((String) jdkNames.getSelectedItem(), AzurePlugin.cmpntFile); jdkFolderName = cloudVal.substring(cloudVal.indexOf("\\") + 1, cloudVal.length()); } String jdkPath = "%HOME%\\site\\wwwroot\\jdk\\" + jdkFolderName; String serverPath = "%programfiles(x86)%\\" + WAHelper .generateServerFolderName(config.getJavaContainer(), config.getJavaContainerVersion()); WebAppConfigOperations.prepareWebConfigForCustomJDKServer(tmpPath, jdkPath, serverPath); InputStream input = new FileInputStream(tmpPath); ftp.storeFile(ftpPath + message("configName"), input); cleanup(ftp); ftp.logout(); } catch (Exception e) { AzurePlugin.log(e.getMessage(), e); } finally { if (ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException ignored) { } } } } } }
From source file:GestoSAT.GestoSAT.java
public boolean actualizarConfiguracion(Vector<String> mySQL, Vector<String> confSeg, int iva, String logo) throws Exception { FileReader file;// w ww . j ava 2s.c o m try { this.iva = Math.abs(iva); BufferedImage image = null; byte[] imageByte; BASE64Decoder decoder = new BASE64Decoder(); imageByte = decoder.decodeBuffer(logo.split(",")[1]); ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); image = ImageIO.read(bis); bis.close(); // write the image to a file File outputfile = new File("logo"); String formato = logo.split("/")[1].split(";")[0]; ImageIO.write(image, formato, outputfile); // MySQL if (mySQL.elementAt(0).equals(this.mySQL.elementAt(0))) { if (!mySQL.elementAt(1).equals(this.mySQL.elementAt(1)) && !mySQL.elementAt(2).equals(this.mySQL.elementAt(2)) && (!mySQL.elementAt(3).equals(this.mySQL.elementAt(3)) || !mySQL.elementAt(0).equals(""))) { Class.forName("com.mysql.jdbc.Driver"); this.con.close(); this.con = DriverManager.getConnection("jdbc:mysql://" + mySQL.elementAt(0) + ":" + Math.abs(Integer.parseInt(mySQL.elementAt(1))) + "/gestosat?user=" + mySQL.elementAt(2) + "&password=" + mySQL.elementAt(3)); this.mySQL.set(0, mySQL.elementAt(0)); this.mySQL.set(1, Math.abs(Integer.parseInt(mySQL.elementAt(1))) + ""); this.mySQL.set(2, mySQL.elementAt(2)); this.mySQL.set(3, mySQL.elementAt(3)); } } else { // Comprobar que pass != "" Process pGet = Runtime.getRuntime() .exec("mysqldump -u " + this.mySQL.elementAt(2) + " -p" + this.mySQL.elementAt(3) + " -h " + this.mySQL.elementAt(0) + " -P " + this.mySQL.elementAt(1) + " gestosat"); InputStream is = pGet.getInputStream(); FileOutputStream fos = new FileOutputStream("backupGestoSAT.sql"); byte[] bufferOut = new byte[1000]; int leido = is.read(bufferOut); while (leido > 0) { fos.write(bufferOut, 0, leido); leido = is.read(bufferOut); } fos.close(); Class.forName("com.mysql.jdbc.Driver"); this.con.close(); this.con = DriverManager.getConnection( "jdbc:mysql://" + mySQL.elementAt(0) + ":" + Math.abs(Integer.parseInt(mySQL.elementAt(1))) + "/gestosat?user=" + mySQL.elementAt(2) + "&password=" + mySQL.elementAt(3)); this.mySQL.set(0, mySQL.elementAt(0)); this.mySQL.set(1, Math.abs(Integer.parseInt(mySQL.elementAt(1))) + ""); this.mySQL.set(2, mySQL.elementAt(2)); this.mySQL.set(3, mySQL.elementAt(3)); Process pPut = Runtime.getRuntime() .exec("mysql -u " + mySQL.elementAt(2) + " -p" + mySQL.elementAt(3) + " -h " + mySQL.elementAt(0) + " -P " + Math.abs(Integer.parseInt(mySQL.elementAt(1))) + " gestosat"); OutputStream os = pPut.getOutputStream(); FileInputStream fis = new FileInputStream("backupGestoSAT.sql"); byte[] bufferIn = new byte[1000]; int escrito = fis.read(bufferIn); while (escrito > 0) { os.write(bufferIn, 0, leido); escrito = fis.read(bufferIn); } os.flush(); os.close(); fis.close(); } // FTP FTPClient cliente = new FTPClient(); if (!confSeg.elementAt(3).equals("")) { cliente.connect(confSeg.elementAt(0), Integer.parseInt(confSeg.elementAt(1))); if (cliente.login(confSeg.elementAt(2), confSeg.elementAt(3))) { cliente.setFileType(FTP.BINARY_FILE_TYPE); BufferedInputStream buffIn = new BufferedInputStream(new FileInputStream("backupGestoSAT.sql")); cliente.enterLocalPassiveMode(); cliente.storeFile("backupGestoSAT.sql", buffIn); buffIn.close(); cliente.logout(); cliente.disconnect(); this.confSeg = confSeg; } else return false; } File archConf = new File("confGestoSAT"); BufferedWriter bw = new BufferedWriter(new FileWriter(archConf)); bw.write(this.mySQL.elementAt(0) + ";" + Math.abs(Integer.parseInt(this.mySQL.elementAt(1))) + ";" + this.mySQL.elementAt(2) + ";" + this.mySQL.elementAt(3) + ";" + this.confSeg.elementAt(0) + ";" + Math.abs(Integer.parseInt(this.confSeg.elementAt(1))) + ";" + this.confSeg.elementAt(2) + ";" + this.confSeg.elementAt(3) + ";" + Math.abs(iva)); bw.close(); return true; } catch (Exception ex) { file = new FileReader("confGestoSAT"); BufferedReader b = new BufferedReader(file); String cadena; cadena = b.readLine(); String[] valores = cadena.split(";"); this.mySQL.add(valores[0]); this.mySQL.add(Math.abs(Integer.parseInt(valores[1])) + ""); this.mySQL.add(valores[2]); this.mySQL.add(valores[3]); con.close(); Class.forName("com.mysql.jdbc.Driver"); con = DriverManager .getConnection("jdbc:mysql://" + this.mySQL.elementAt(0) + ":" + this.mySQL.elementAt(1) + "/gestosat?user=" + this.mySQL.elementAt(2) + "&password=" + this.mySQL.elementAt(3)); this.confSeg.add(valores[4]); this.confSeg.add(Math.abs(Integer.parseInt(valores[5])) + ""); this.confSeg.add(valores[6]); this.confSeg.add(valores[7]); file.close(); Logger.getLogger(GestoSAT.class.getName()).log(Level.SEVERE, null, ex); return false; } }
From source file:com.sos.VirtualFileSystem.FTP.SOSVfsFtpBaseClass.java
/** * Using Binary mode for file transfers/*from w ww . j a va 2s . c o m*/ * @return True if successfully completed, false if not. * @throws IOException If an I/O error occurs while either sending a * command to the server or receiving a reply from the server. */ @Override public void binary() { try { boolean flgResult = Client().setFileType(FTP.BINARY_FILE_TYPE); if (flgResult == false) { throw new JobSchedulerException(SOSVfs_E_149.params(getReplyString())); } } catch (IOException e) { throw new JobSchedulerException(SOSVfs_E_130.params("setFileType to binary"), e); } }