Posts tagged Class
PHP Query String Class
0This class can manipulate query strings used in HTTP requests that are used to pass arguments and values to page scripts.
It can get and set argument values, delete arguments and count the number of ocurrences in a given query string.
Download source code from:
http://www.phpclasses.org/browse/package/2378.html
Or from this blog:
A Java Class to upload files trough FTP
0Download Ftp.java
/**
* FILE: Ftp.java
* DESCRIPTION: A ftp uploader GUI class
* LIMITATION: Uses AWT instead of SWING
* VERSION: 09-Feb-2006
*
* Olaf says:
*
* -- Remenber, all is posible but the problem
* is the time you are able to spend doing it. --
*/
import java.io.*;
import java.net.*;
import java.awt.*;
/**
* An ftp uploader class (GUI File Selector)
* @author Olaf Reitmaier (olafrv@gmail.com)
*/
public class Ftp{
public static void main(String args[]) throws Exception{
int PIECE_SIZE = 7000; //Byte transfer rate (56 Kbps = 7KB)
int bytes = 0; //Temp var of read bytes
byte[] piece = new byte[PIECE_SIZE]; //Temp var of file pieces
String server = "a_server_ip"; //The ftp server
String user = "an_user"; //The ftp user
String password = "a_passwd"; //The ftp password
String[] files=selectFile();
if(files[0]!=null && files[1]!=null){
String localFile = files[0]+File.separator+files[1];
String remoteFile = "/"+files[1];
String strUrl = "ftp://"+user+":"+password+"@"+server+remoteFile+";type=i";
URL url = new URL(strUrl);
URLConnection urlc = url.openConnection();
FileInputStream fis = new FileInputStream(new File(localFile));
OutputStream os = urlc.getOutputStream();
while(true){
bytes = fis.available();
if (bytes<=0){ break; }else{ if (bytes>=PIECE_SIZE){
fis.read(piece,0,PIECE_SIZE);
os.write(piece,0,PIECE_SIZE);
}else{
fis.read(piece,0,bytes);
os.write(piece,0,bytes);
}
}
}
os.close(); //Close the remote file stream
fis.close(); //Close the local file stream
}
}
/**
* An AWT File Chooser
* Courtesy of Jose Carrero <josercl@gmail.com>
* @return A string array with the first position
* containing the fullpath of the selected file
*/
public static String[] selectFile(){
String[] files=new String[2];
Frame frame=new Frame();
FileDialog file_chooser=new FileDialog(frame);
file_chooser.show();
files[0]=file_chooser.getDirectory();
files[1]=file_chooser.getFile();
file_chooser.dispose(); //Needed to terminates the program
frame.dispose(); //Needed to terminates the program
return files;
}
}
Blowfish Cipher Algorithm in Java
2Download source code here: Blowfish.tar.gz
An implementation on Blowfish cipher algorithm in Java, based on:
* Bruce Schneier (2009)
* Dr. Herong Yang (2009)
* Wikipedia (2009)
* DI Managment (2009)
Copyright (C) Dec 23th, 2009 – Olaf Reitmaier Veracierta
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .