This commit is contained in:
parent
51e9da7c9b
commit
ca8f6278b1
30 changed files with 88 additions and 79 deletions
|
|
@ -7,7 +7,7 @@ package zutil;
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface OneApp {
|
public interface OneInstance {
|
||||||
/**
|
/**
|
||||||
* Checks if the application is already running
|
* Checks if the application is already running
|
||||||
*
|
*
|
||||||
|
|
@ -12,7 +12,7 @@ import java.nio.channels.OverlappingFileLockException;
|
||||||
*
|
*
|
||||||
* @author Ziver Koc
|
* @author Ziver Koc
|
||||||
*/
|
*/
|
||||||
public class OneAppFile implements OneApp{
|
public class OneInstanceFile implements OneInstance{
|
||||||
private File file;
|
private File file;
|
||||||
private FileChannel channel;
|
private FileChannel channel;
|
||||||
private FileLock lock;
|
private FileLock lock;
|
||||||
|
|
@ -22,7 +22,7 @@ public class OneAppFile implements OneApp{
|
||||||
*
|
*
|
||||||
* @param filename The name of the file to be locked
|
* @param filename The name of the file to be locked
|
||||||
*/
|
*/
|
||||||
public OneAppFile(String filename){
|
public OneInstanceFile(String filename){
|
||||||
this.file = new File(System.getProperty("user.home"), filename);
|
this.file = new File(System.getProperty("user.home"), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4,13 +4,15 @@ import java.io.IOException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class checks if the app is alredy running
|
* This class checks if the app is alredy running
|
||||||
* by Locking a port
|
* by Locking a port
|
||||||
*
|
*
|
||||||
* @author Ziver Koc
|
* @author Ziver Koc
|
||||||
*/
|
*/
|
||||||
public class OneAppNetwork extends Thread implements OneApp{
|
public class OneInstanceNetwork extends Thread implements OneInstance{
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -18,7 +20,7 @@ public class OneAppNetwork extends Thread implements OneApp{
|
||||||
*
|
*
|
||||||
* @param port The port to lock
|
* @param port The port to lock
|
||||||
*/
|
*/
|
||||||
public OneAppNetwork(int port){
|
public OneInstanceNetwork(int port){
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3,7 +3,7 @@ package zutil.algo;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Euclidean algorithm is an algorithm to determine
|
* Euclidean algorithm is an algorithm to determine
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
|
||||||
import zutil.converters.Converter;
|
import zutil.converters.Converter;
|
||||||
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class creates a queue that stors the
|
* This class creates a queue that stors the
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package zutil;
|
package zutil.io;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
@ -13,6 +13,8 @@ import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import zutil.Dumpable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
* this class can print strings to multiple PrintStreams
|
* this class can print strings to multiple PrintStreams
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package zutil;
|
package zutil.io.file;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
|
@ -10,8 +10,7 @@ import java.io.File;
|
||||||
public interface FileChangeListener{
|
public interface FileChangeListener{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when there is a change in
|
* This method is called when there is a change in a file
|
||||||
* a file
|
|
||||||
*
|
*
|
||||||
* @param file The file that has changed
|
* @param file The file that has changed
|
||||||
*/
|
*/
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package zutil;
|
package zutil.io.file;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
|
@ -14,6 +14,8 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File path utilities
|
* File path utilities
|
||||||
*
|
*
|
||||||
|
|
@ -172,9 +174,9 @@ public class FileUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as search(File dir)
|
* Same as search(File dir) but it caches the result
|
||||||
* but is caches the result to be used next time this function is called
|
* to be used next time this function is called with
|
||||||
* with the same parameters.
|
* the same parameters.
|
||||||
*/
|
*/
|
||||||
public static List<File> cachedSearch(File dir){
|
public static List<File> cachedSearch(File dir){
|
||||||
return cachedSearch(dir, new LinkedList<File>(), true);
|
return cachedSearch(dir, new LinkedList<File>(), true);
|
||||||
|
|
@ -182,8 +184,8 @@ public class FileUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as search(File dir, List<File> fileList, boolean recursive)
|
* Same as search(File dir, List<File> fileList, boolean recursive)
|
||||||
* but is caches the result to be used next time this function is called
|
* but is caches the result to be used next time this function is
|
||||||
* with the same parameters.
|
* called with the same parameters.
|
||||||
*/
|
*/
|
||||||
public static List<File> cachedSearch(File dir, List<File> fileList, boolean recursive){
|
public static List<File> cachedSearch(File dir, List<File> fileList, boolean recursive){
|
||||||
return cachedSearch(dir, new LinkedList<File>(), false, (recursive ? Integer.MAX_VALUE : 0));
|
return cachedSearch(dir, new LinkedList<File>(), false, (recursive ? Integer.MAX_VALUE : 0));
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
package zutil;
|
package zutil.io.file;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class calls a given listener
|
* This class calls a given listener
|
||||||
* when a file is changed
|
* when a file is changed
|
||||||
|
*
|
||||||
* @author Ziver
|
* @author Ziver
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
@ -20,7 +23,7 @@ public class FileWatcher extends TimerTask{
|
||||||
* Creates a watcher for the given file whit the check
|
* Creates a watcher for the given file whit the check
|
||||||
* interval of 1 second
|
* interval of 1 second
|
||||||
*
|
*
|
||||||
* @param file The file to check
|
* @param file is the file to check
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
public FileWatcher(File file) throws FileNotFoundException{
|
public FileWatcher(File file) throws FileNotFoundException{
|
||||||
|
|
@ -31,12 +34,13 @@ public class FileWatcher extends TimerTask{
|
||||||
* Creates a watcher for the given file whit the given
|
* Creates a watcher for the given file whit the given
|
||||||
* check interval
|
* check interval
|
||||||
*
|
*
|
||||||
* @param file The file
|
* @param file is the file
|
||||||
* @param intervall The interval
|
* @param intervall is the interval
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
*/
|
*/
|
||||||
public FileWatcher(File file, int intervall) throws FileNotFoundException{
|
public FileWatcher(File file, int intervall) throws FileNotFoundException{
|
||||||
if(file==null || !file.exists()) throw new FileNotFoundException("File not found: "+file);
|
if(file==null || !file.exists())
|
||||||
|
throw new FileNotFoundException("File not found: "+file);
|
||||||
this.file = file;
|
this.file = file;
|
||||||
lastChanged = file.lastModified();
|
lastChanged = file.lastModified();
|
||||||
|
|
||||||
|
|
@ -27,8 +27,8 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||||
import org.apache.commons.fileupload.util.Streams;
|
import org.apache.commons.fileupload.util.Streams;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
|
||||||
import zutil.StringUtil;
|
import zutil.StringUtil;
|
||||||
|
import zutil.io.file.FileUtil;
|
||||||
import zutil.jee.upload.FileUploadListener.Status;
|
import zutil.jee.upload.FileUploadListener.Status;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
import zutil.parser.json.JSONNode;
|
import zutil.parser.json.JSONNode;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.security.auth.login.AccountException;
|
import javax.security.auth.login.AccountException;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple FTP client class
|
* A simple FTP client class
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import java.net.DatagramSocket;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.MulticastSocket;
|
import java.net.MulticastSocket;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class broadcast its address in the LAN so that
|
* This class broadcast its address in the LAN so that
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ import java.io.ObjectOutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
|
||||||
import zutil.MultiPrintStream;
|
|
||||||
import zutil.ProgressListener;
|
import zutil.ProgressListener;
|
||||||
|
import zutil.io.MultiPrintStream;
|
||||||
|
import zutil.io.file.FileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class connects to a update server and updates a path
|
* This class connects to a update server and updates a path
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
|
||||||
import zutil.Hasher;
|
import zutil.Hasher;
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
|
import zutil.io.file.FileUtil;
|
||||||
|
|
||||||
public class UpdateServer extends Thread{
|
public class UpdateServer extends Thread{
|
||||||
private ArrayList<FileHash> fileList;
|
private ArrayList<FileHash> fileList;
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ import java.util.Map;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import zutil.Encrypter;
|
import zutil.Encrypter;
|
||||||
import zutil.MultiPrintStream;
|
|
||||||
import zutil.converters.Converter;
|
import zutil.converters.Converter;
|
||||||
import zutil.io.DynamicByteArrayStream;
|
import zutil.io.DynamicByteArrayStream;
|
||||||
|
import zutil.io.MultiPrintStream;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
import zutil.network.nio.message.type.ResponseRequestMessage;
|
import zutil.network.nio.message.type.ResponseRequestMessage;
|
||||||
import zutil.network.nio.message.type.SystemMessage;
|
import zutil.network.nio.message.type.SystemMessage;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package zutil.network.nio.response;
|
package zutil.network.nio.response;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
public class PrintRsp extends ResponseEvent{
|
public class PrintRsp extends ResponseEvent{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package zutil.network.nio.worker;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
public class EchoWorker extends ThreadedEventWorker {
|
public class EchoWorker extends ThreadedEventWorker {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import java.io.IOException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
import zutil.network.nio.NioClient;
|
import zutil.network.nio.NioClient;
|
||||||
import zutil.network.nio.message.GridMessage;
|
import zutil.network.nio.message.GridMessage;
|
||||||
import zutil.network.nio.worker.ThreadedEventWorker;
|
import zutil.network.nio.worker.ThreadedEventWorker;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import java.util.TimerTask;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
import zutil.io.StringOutputStream;
|
import zutil.io.StringOutputStream;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
import zutil.network.http.HTTPHeaderParser;
|
import zutil.network.http.HTTPHeaderParser;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import java.security.cert.CertificateException;
|
||||||
|
|
||||||
import javax.net.ssl.SSLServerSocketFactory;
|
import javax.net.ssl.SSLServerSocketFactory;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
|
|
||||||
public class Torrent {
|
public class Torrent {
|
||||||
// Name of the torrent
|
// Name of the torrent
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
import zutil.io.MultiPrintStream;
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.file.FileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://wiki.theory.org/BitTorrentSpecification
|
* http://wiki.theory.org/BitTorrentSpecification
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.dom4j.DocumentException;
|
import org.dom4j.DocumentException;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
import zutil.network.http.HttpPage;
|
import zutil.network.http.HttpPage;
|
||||||
import zutil.network.http.HttpPrintStream;
|
import zutil.network.http.HttpPrintStream;
|
||||||
import zutil.network.upnp.UPnPService;
|
import zutil.network.upnp.UPnPService;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package zutil.parser.json;
|
package zutil.parser.json;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
import zutil.parser.json.JSONNode.JSONType;
|
import zutil.parser.json.JSONNode.JSONType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import zutil.FileChangeListener;
|
import zutil.io.file.FileChangeListener;
|
||||||
import zutil.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
import zutil.FileWatcher;
|
import zutil.io.file.FileWatcher;
|
||||||
|
|
||||||
public class FileChangedTest implements FileChangeListener{
|
public class FileChangedTest implements FileChangeListener{
|
||||||
public static void main(String[] args) throws URISyntaxException, FileNotFoundException{
|
public static void main(String[] args) throws URISyntaxException, FileNotFoundException{
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import java.io.File;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
|
||||||
import zutil.Hasher;
|
import zutil.Hasher;
|
||||||
|
import zutil.io.file.FileUtil;
|
||||||
|
|
||||||
public class FileFinderHasherTest {
|
public class FileFinderHasherTest {
|
||||||
public static void main(String[] args) throws URISyntaxException{
|
public static void main(String[] args) throws URISyntaxException{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import javax.wsdl.WSDLException;
|
import javax.wsdl.WSDLException;
|
||||||
|
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.MultiPrintStream;
|
||||||
import zutil.network.http.HttpServer;
|
import zutil.network.http.HttpServer;
|
||||||
import zutil.network.http.soap.SOAPHttpPage;
|
import zutil.network.http.soap.SOAPHttpPage;
|
||||||
import zutil.network.ssdp.SSDPServer;
|
import zutil.network.ssdp.SSDPServer;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ import javax.swing.text.Document;
|
||||||
import javax.swing.text.Style;
|
import javax.swing.text.Style;
|
||||||
import javax.swing.text.StyleConstants;
|
import javax.swing.text.StyleConstants;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
import zutil.io.file.FileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Swing console window Thats takes System.in and
|
* Creates a Swing console window Thats takes System.in and
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import java.io.IOException;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
|
||||||
import zutil.image.ImageUtil;
|
import zutil.image.ImageUtil;
|
||||||
|
import zutil.io.file.FileUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a panel with a background image
|
* This class is a panel with a background image
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ import javax.swing.WindowConstants;
|
||||||
import javax.swing.GroupLayout.Alignment;
|
import javax.swing.GroupLayout.Alignment;
|
||||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||||
|
|
||||||
import zutil.FileUtil;
|
import zutil.io.MultiPrintStream;
|
||||||
import zutil.MultiPrintStream;
|
import zutil.io.file.FileUtil;
|
||||||
import zutil.struct.HistoryList;
|
import zutil.struct.HistoryList;
|
||||||
import zutil.ui.JImagePanel;
|
import zutil.ui.JImagePanel;
|
||||||
import zutil.ui.wizard.listener.BlockingWizardListener;
|
import zutil.ui.wizard.listener.BlockingWizardListener;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue