那么文件"MyStore.obj"和我下载的表一起附上了.我应该阅读这个文件的内容,这是与内容的顺序给出的.我可以确定它是否存在?因为你可以看到我尝试使用方法exists()但它没有用
import java.io.*;
public class sheet{
public static void main(String[]args){
try{
FileInputStream fis=new FileInputStream("MyStore.obj");
if(("MyStore.obj").exists()==false) //what can i do to fix this?
throw new FileNotFoundException("file doesn't exist");
ObjectInputStream ois=new ObjectInputStream(fis);
int numOfStorageDevice=ois.readInt();
int numOfComputerGames=ois.readInt();
StorageDevice [] sd=new StorageDevice[numOfStorageDevice];
for(int n=0;n<numOfStorageDevice;n++)
sd[n]=(StorageDevice)ois.readObject();
ComputerGame []cg=new ComputerGame[numOfComputerGames];
for(int m=0;m<numOfComputerGames;m++)
cg[m]=(ComputerGame)ois.readObject();
File file=new File("Result.txt");
FileOutputStream fos=new FileOutputStream(file);
PrintWriter pr=new PrintWriter(fos);
for(int i=0;i<numOfStorageDevice;i++){
String model= sd[i].getmodel();
/*and in the methodcall sd[i].getmodel() it keeps telling that
the symbol cannot be found but i'm sure that the …Run Code Online (Sandbox Code Playgroud) 人员表引用分支表
CREATE TABLE Staff(
StaffNo VARCHAR(5) NOT NULL,
firstName VARCHAR(15) NOT NULL UNIQUE,
lastName VARCHAR(15) NOT NULL,
position VARCHAR(10) NOT NULL,
salary INTEGER
DEFAULT 3000,
CHECK (salary BETWEEN 3000 AND 25000),
email VARCHAR(25),
branchNo CHAR(6) NOT NULL,
PRIMARY KEY (StaffNo),
FOREIGN KEY (branchNo) REFERENCES Branch (branchNo));
Run Code Online (Sandbox Code Playgroud)
同时分支表引用了Staff表
create table Branch(
branchNo char(6) not null primary key,
street varchar(30) not null,
city varchar(20),
postCode char(5) not null,
ManagerNo varchar(5) not null,
foreign key (ManagerNo) references Staff(StaffNo));
Run Code Online (Sandbox Code Playgroud)