⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cutone.java

📁 Java切割机 一个很好的Java切割机
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
						}
						else{
							JOptionPane.showMessageDialog(Wnd,"失败--请检查文件是否在同一目录中","CofeCut",
								JOptionPane.ERROR_MESSAGE);
						}
					}
					else{
							JOptionPane.showMessageDialog(Wnd,"失败--Key文件被破坏","CofeCut",
								JOptionPane.ERROR_MESSAGE);
						}

				}
				else{
					JOptionPane.showMessageDialog(Wnd,"文件或目录不存在","CofeCut",
								JOptionPane.ERROR_MESSAGE);
				}
			}
	else if(e.getSource() == jMenuItem1){ System.exit(0);}
        else if(e.getSource() == jButton1){ GPL gplwin= new GPL();
                                             	gplwin.setLocation(80,40);
    						gplwin.setSize(500,300);
						
						gplwin.show();
                                                    }
		//if Last }
		}


     ////////////////////////////////////////////////////////
     ///////////////PPCutFile1.1此程序用于把文件切开///////////
     ////////////////////////////////////////////////////////

public class CutFile
{
	CutFile(String FileDir,String FileName){
		this.FileDir = FileDir;
		this.FileName = FileName;
	}

	public boolean ReadFile(){
		try{
			InputFile = new File(FileDir+FileName);
			System.out.println(FileDir);
			System.out.println(FileName);
			if(InputFile.isFile()&&InputFile.canRead()&&InputFile.exists()){
				fileInputStream =  new DataInputStream(new BufferedInputStream(
	  				new FileInputStream(InputFile)));
	  				return true;
	  		}
	  		else{
	  			System.out.println("文件不存在...");
	  			return false;
	  		}
	  	}
	  	catch(Exception e)
	  	{return false;}
	}
	public int FileNumber(float FileWeight){
		CountFileNumber = (int)(InputFile.length()/FileWeight);
		if(InputFile.length()%FileWeight>0)
			CountFileNumber++;
		this.FileWeight=FileWeight;
		return CountFileNumber;
	}
	public void DoCut(){
		try{
			int test;
			for(int i=0;i<CountFileNumber;i++){
				fileOutStream = new DataOutputStream(new BufferedOutputStream(
	  			new FileOutputStream(new File(FileDir+i+FileName+".ccf"))));
				for(int j=0;j<(int)FileWeight;j++){
					test=fileInputStream.read();
					if(test==-1)
						break;
				    fileOutStream.write(test);
				}
				fileOutStream.flush();
			}
			fileInputStream.close();
			fileOutStream.close();
		}
		catch(IOException e){
			e.printStackTrace();
		}
	}
	public void CreateKey(){
		try{
			fileOutStream = new DataOutputStream(
	  			new FileOutputStream(new File(FileDir+"key"+FileName+".ccf")));
			fileOutStream.writeChars("CofeCut1.0");
			fileOutStream.writeInt(CountFileNumber);
			fileOutStream.close();

		}
		catch(IOException e)
		{e.printStackTrace();}
	}

	private int CountFileNumber;
	private float FileWeight;
	private String CreateFile;
	private File InputFile;
	private File OutputFile;
	private String FileName;
	private String FileDir;
	private DataInputStream fileInputStream;
	private DataOutputStream fileOutStream;

}

////////////////////////////////////////////////////////
/////////////PPLinkFile1.1此程序用于把文件合并////////////
////////////////////////////////////////////////////////


public class LinkFile
{

	public LinkFile(String FileDir,String KeyFile)
	{
		this.FileDir=FileDir;
		this.KeyFile=KeyFile;
		Streams = new Vector();

	}

	public boolean ReadKey()
	{
		char[] KeyChar = new char[10];
		try{
			fileInputStream = new DataInputStream(
				new FileInputStream(FileDir+KeyFile));
			 for(int i=0;i<10;i++){
			 	KeyChar[i] =fileInputStream.readChar();
			 }

			if(TheKey.equals(new String(KeyChar))){
				CountFileNumber = fileInputStream.readInt();
				return true;
			}
			System.out.println("KeyFile has broken!");
			return false;
		}
		catch(IOException e)
		{e.printStackTrace();return false;}
	}

	public boolean DoLink(){
		try{
			FileName = KeyFile.substring(3,KeyFile.length());
			for(int i=0;i<CountFileNumber;i++){
				if(new File(FileDir+i+FileName).isFile()){
				Streams.addElement(new BufferedInputStream( new FileInputStream(FileDir+i+FileName)));}
				else
				{return false;}
			}
			FileName = KeyFile.substring(0,KeyFile.length()-4);
		    fileOutStream= new DataOutputStream(new BufferedOutputStream(
	  			new FileOutputStream(new File(FileDir+FileName))));
			AddStream = new SequenceInputStream(Streams.elements());
			int c;
			while((c = AddStream.read())!=-1){
				fileOutStream.write(c);
			}
			AddStream.close();
			fileOutStream.close();
			return true;
		}
		catch(IOException e)
		{e.printStackTrace();return false;}
	}

	private Vector Streams;
	private int CountFileNumber;
	private DataOutputStream fileOutStream = null;
	private DataInputStream fileInputStream = null;
	private File OutputFile = null;
	private String KeyFile = null;
	private String FileDir = null;
	private String TheKey = "CofeCut1.0";
	private String FileName = null;
	private SequenceInputStream AddStream = null;

}



       /////////////////////////////////////////////////////////
       /////////PPKeyIn1.1此程序用于从控制台得到数据///////////////
       /////////////////////////////////////////////////////////


public class KeyIn
{

	public KeyIn(){KeyBoardInput = new BufferedReader
		 (new InputStreamReader(System.in));}
	//从控制台得到float类型的数据
	public float KeyInFloat(){
		try{
		    for(;;){
		    	Input = KeyBoardInput.readLine();
		    	char[]mychar=Input.toCharArray();
		    	for(int i=0;i<mychar.length;i++){
		    		ischar=Character.isDigit(mychar[i])||mychar[i]=='.';
		    		if(ischar==false){
		    			Input+="some chars are not digit";
		       			break;
		    		}
		    	}

		    	if(Input.length()>20||Input.equals("")){
		        	System.out.println("输入数据不合法");
		    	}

		    	else{
		       		Float floater = new Float(Input);
		    		theFloat=floater.floatValue();
		    		return theFloat;
		    	}

		  	 }
	    	}
		catch(IOException e){
			e.printStackTrace();
			return -1;
		}
	}
	//从控制台得到int类型的数据
	public int KeyInInt(){
		try{
		    for(;;){
		    	Input = KeyBoardInput.readLine();
		    	char[]mychar=Input.toCharArray();
		    	for(int i=0;i<mychar.length;i++){
		    		ischar=Character.isDigit(mychar[i]);
		    		if(ischar==false){
		    			Input+="some chars are not digit";
		       			break;
		    		}
		    	}

		    	if(Input.length()>10||Input.equals("")){
		        	System.out.println("输入数据不合法");
		    	}

		    	else{
		       		Integer integer = new Integer(Input);
		    		theInt=integer.intValue();
		    		return theInt;
		    	}

		  	 }
	    	}
		catch(IOException e){
			e.printStackTrace();
			return -1;
		}
	}
	public String KeyInString(){
		try{
			return KeyBoardInput.readLine();
		}
		catch(IOException e)
		{e.printStackTrace();return null;}
	}
	private BufferedReader KeyBoardInput;
	private String Input;
	private float theFloat;
    private boolean ischar;
    private int theInt;

}


//Last }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -