fileio.java
来自「一个简单的visio程序。」· Java 代码 · 共 189 行
JAVA
189 行
package HPCore.stdfunc;
import HPCore.stdstmt.hpfileio;
import HPCore.Exception.*;
import HECore.stddata.*;
import java.util.*;
public class fileio{
/**
* Returns a date (VarType 7) that indicates the date and time when a
* file was created or last modified.
*
* The pathname argument is a string expression that specifies a filename.
* The pathname may include the directory and the drive.
*/
static final char fseparator = System.getProperty("file.separator").charAt(0);
public static HDate filedatetime(String pathname) throws HpException
{
String fname = pathname.replace('\\',fseparator);
java.io.File file;
long dt = 0;
int hour;
HDate time = new HDate(0);
UdtDatetime Datetime = new UdtDatetime();
//Calendar calendar = Calendar.getInstance();
file = new java.io.File(fname);
if (file.exists() || file.isDirectory() )
{
dt = file.lastModified();
Date date = new Date();
date.setTime(dt);
//calendar.setTime(date);
//int am_pm = calendar.get( Calendar.AM_PM);
int am_pm = date.getHours();
if( System.getProperty("os.name").toLowerCase().compareTo("windows nt" )!=0 )
hour = am_pm <= 12 ? (date.getHours()+20) : (date.getHours()+8);
else
hour = am_pm <= 12 ? (date.getHours()+12) : (date.getHours());
int[] m_VBDate = {date.getMonth()+1,
date.getDate(),
date.getYear(),
hour,//calendar.get(Calendar.HOUR)
date.getMinutes(),
date.getSeconds()
};
GGRESULT ddate = Datetime.dtcommon(m_VBDate);
time = new HDate(ddate.valued+ddate.valuet);
}
else
throw new HpException(53, "File not found");
return time;
}
/**
* Returns the size, in bytes, of a file opened using the Open statement.
*
* The filenumber argument is any valid file number.
*/
public static int lof(short filenumber) throws HpException
{
return hpfileio.lof(filenumber);
}
/**
* Returns the length of a file in bytes.
*
* The pathname argument is a string expression that specifies a file.
* The pathname may include the directory and the drive.
*/
public static int filelen(String pathname) throws HpException
{
return hpfileio.filelen(pathname);
}
/**
* Returns a number representing the attributes of a file or directory.
*
* The pathname argument is a string expression that specifies a filename.
* The pathname may include the directory and the drive.
*/
public static int getattr(String pathname) throws HpException
{
return hpfileio.getattr(pathname);
}
/**
* Returns file mode or operating system file handle information
* for files opened using the Open statement.
*
* filenumber : Any valid file number.
* returntype : Number indicating the type of information to return.
* Specify 1 to return a value indicating the file mode.
* Specify 2 to return the operating system file handle.
*/
public static int fileattr(short filenumber,short returntype) throws HpException
{
return hpfileio.fileattr(filenumber,returntype);
}
/**
* Returns a value that indicates whether the end of a file has been
* reached.
*
* The filenumber argument is any valid file number.
*/
public static int eof(short filenumber) throws HpException
{
return hpfileio.eof(filenumber);
}
/**
* Returns characters from an open sequential or binary file.
*
* number : Any valid numeric expression specifying the number of
* characters to return.
* filenumber : Any valid file number.
*/
public static Variant input(short number,short filenumber) throws HpException
{
return hpfileio.input(number,filenumber);
}
/**
* Returns characters from an open sequential or binary file.
*
* number : Any valid numeric expression specifying the number of
* characters to return.
* filenumber : Any valid file number.
*/
public static String input$(short number,short filenumber) throws HpException
{
return hpfileio.input$(number,filenumber);
}
/**
* Returns the current read/write position within an open file.
*
* The filenumber argument is any valid file number.
*/
public static int loc(short filenumber) throws HpException
{
return hpfileio.loc(filenumber);
}
/**
* Returns the current read/write position within a file opened using
* the Open statement.
*
* The filenumber argument is any valid file number.
*/
public static int seek(short filenumber) throws HpException
{
return hpfileio.seek(filenumber);
}
/**
* Returns the next file number available for use by the Open
* statement.
*
* The rangenumber argument specifies the range from which the next free
* file number is to be returned. Specify a 0 (default) to return a file
* number in the range 1 to 255, inclusive. Specify a 1 to return a file
* number in the range 256 to 511.
*/
public static short freefile(short rangenumber) throws HpException
{
return hpfileio.freefile(rangenumber);
}
/**
* Returns the next file number available for use by the Open
* statement.
*/
public static short freefile() throws HpException
{
return hpfileio.freefile();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?