📄 cao.java
字号:
package huayi.gg.cao;
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.naming.*;
/**
* 从连接池中取得一个空闲的数据库连接
* @return Connection
* @exception Exception
*/
public class cao{
String houzhui=null;
File f1;
RandomAccessFile random;
FileOutputStream o;
String secondLine;
int second=1;
int position;
String fileName=null;
byte b[]=new byte[10000];
int n;
public cao(){
}
public String getName(InputStream in,String tempFileName)
{
try
{
f1=new File("C:/",tempFileName);
o=new FileOutputStream(f1);
while((n=in.read(b))!=-1){o.write(b,0,n);}
o.close();
in.close();
random=new RandomAccessFile(f1,"r");
secondLine=null;
while(second<=2)
{secondLine=random.readLine();second++;}
position=secondLine.lastIndexOf('\\');
fileName=secondLine.substring(position+1,(secondLine.length()-1));
int position0=fileName.lastIndexOf('.');
houzhui=fileName.substring((position0+1),fileName.length());
return fileName;
}
catch(IOException e){}
return fileName;
}
public String file()
{return fileName;}
//文件上传
public void transfer(String sql)
{
try
{
random.seek(0);
long forthEndPosition=0;
int forth=1;
while((n=random.readByte())!=-1&&(forth<=4))
{
if(n=='\n')
{
forthEndPosition=random.getFilePointer();
forth++;
}
}
File f2=new File("C:/",fileName);
RandomAccessFile random2=new RandomAccessFile(f2,"rw");
random.seek(random.length());
long endPosition=random.getFilePointer();
long mark=endPosition;
int j=1;
while((mark>=0)&&(j<=6))
{
mark--;
random.seek(mark);
n=random.readByte();
if(n=='\n')
{endPosition=random.getFilePointer();j++;}
}
random.seek(forthEndPosition);
long startPoint=random.getFilePointer();
while(startPoint<(endPosition-1))
{
n=random.readByte();
random2.write(n);
startPoint=random.getFilePointer();
}
random2.close();
random.close();
f1.delete();
//f2.delete();
}
catch(IOException e){}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -