当前位置: 首页>>代码示例>>Java>>正文


Java FileConnection类代码示例

本文整理汇总了Java中javax.microedition.io.file.FileConnection的典型用法代码示例。如果您正苦于以下问题:Java FileConnection类的具体用法?Java FileConnection怎么用?Java FileConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileConnection类属于javax.microedition.io.file包,在下文中一共展示了FileConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: displayAndCalculate

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
public void displayAndCalculate() {
    try {
        Display.getDisplay(this).setCurrent(form);
        FileConnection fileConnection = (FileConnection) Connector.open(textFieldSampleUrl.getString(), Connector.READ);
        InputStream inputStream = fileConnection.openInputStream();
        FileReader fileReader = new FileReader(inputStream);
        String totalString = "";
        Vector lines = fileReader.readLines();
        for (int i = 0; i < lines.size(); i++) {
            String line = (String)lines.elementAt(i);
            totalString += line + "\r\n";
        }
        stringItemStatus.setText(totalString);
    } catch (IOException e) {
    }
}
 
开发者ID:kamcpp,项目名称:heart-diag-app,代码行数:17,代码来源:HeartDiagAppMidlet.java

示例2: displayAndCalculate

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
public void displayAndCalculate() {
    try {            
        Display.getDisplay(this).setCurrent(form);
        FileConnection fileConnection = (FileConnection) Connector.open(textFieldSampleUrl.getString(), Connector.READ);
        InputStream inputStream = fileConnection.openInputStream();
        currentSignal = SignalFactory.fromStream(inputStream);
        ((SimpleSignal) currentSignal).calculateMaxAltitude();
        ((SimpleSignal) currentSignal).calculateHighPoints();
        PanAndTimpkins panAndTimpkins = new PanAndTimpkins();
        panAndTimpkins.analyze(currentSignal);
        String diseaseName;
        if (panAndTimpkins.getDistanceTimeAverage() < 0.6) {
            diseaseName = "Sinus Tachycardia";
        } else if (panAndTimpkins.getDistanceTimeAverage() > 1.0) {
            diseaseName = "Sinus Bradicardia";
        } else if (panAndTimpkins.getDistanceTimeAverage() >= 0.6 && panAndTimpkins.getDistanceTimeAverage() <= 1.0) {
            diseaseName = "HEALTHY - No Disease!";
        } else {
            diseaseName = "Atrial Fibrillation";
        }
        stringItemStatus.setText("Disease: " + diseaseName);
        signalItem.setSignal(currentSignal);
    } catch (IOException e) {
    }
}
 
开发者ID:kamcpp,项目名称:heart-diag-app,代码行数:26,代码来源:HeartDiagAppMidlet.java

示例3: test0007

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests lastModified() in Connector.READ mode
 */
public void test0007() {
	boolean passed = false;
	try {	
		addOperationDesc("Opening connection in READ mode");
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ);
		try {
			long lastModified = conn.lastModified();
			addOperationDesc("lastModified() call returned " + lastModified);
			
			passed = true;								
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}
	
	assertTrueWithLog("Tests lastModified() in Connector.READ mode", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:24,代码来源:LastModified.java

示例4: remove

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
public void remove() throws IOException {
    FileConnection con = connector();

    //TODO: this really needs to be written better, but
    //for now avoiding deadlock is better than ensuring
    //thread safety

    //Take a lock on the connection so that nothing tries
    //to access it while this happens
    synchronized(con) {
        con.delete();
        con.close();
    }

    //Take a lock on the connections so that
    //nothing can retrieve the connection
    synchronized(connections) {
        //Remove the local connection now that it's
        //closed.
        clearReferenceConnection(getLocalURI());
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:J2meFileReference.java

示例5: dumpRMS

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
public static void dumpRMS (String pathPrefix) {
    if (pathPrefix == null)
        pathPrefix = DUMP_PATH_PREFIX_DEFAULT;
    String filepath = dumpFilePath(pathPrefix);

    try {
        FileConnection fc = (FileConnection)Connector.open("file:///" + filepath);
        if (fc.exists()) {
            System.err.println("Error: File " + filepath + " already exists");
            fail("Dump file " + filepath + " already exists");
        }

        fc.create();
        DataOutputStream out = fc.openDataOutputStream();

        dumpRMS(out);

        fc.close();
    } catch (IOException ioe) {
        fail(ioe, "ioexception");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:DumpRMS.java

示例6: test0001

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests isHidden() on a hidden file
 */
public void test0001() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			addOperationDesc("Setting file as hidden");
			conn.setHidden(true);
			
			boolean isHidden = conn.isHidden();
			addOperationDesc("isHidden() returned " + isHidden);
			
			passed = isHidden==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests isHidden() on a hidden file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:IsHidden.java

示例7: generateData

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
void generateData() throws IOException {
    String str = "";
    String part = "abcdefghilmnopqrstuvzABCDEFGHILMNOPQRSTUVZabcdefghilmnopqrstuvzABCDEFGHILMNOPQRSTUVZ";
    for (int i = 0; i < 2000; i++) {
      str += part;
    }

    cbuf = new char[str.length()];
    cbufReader = new char[cbuf.length];
    str.getChars(0, str.length(), cbuf, 0);

    String dirPath = System.getProperty("fileconn.dir.private");
    file = (FileConnection)Connector.open(dirPath + "test");
    if (file.exists()) {
        file.delete();
    }
    file.create();
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:UTF8Bench.java

示例8: test0004

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
public void test0004() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			
			addOperationDesc("Creating directory: " + conn.getURL());
			ensureDirExists(conn);
			
			long modifyTime = conn.lastModified();
			addOperationDesc("lastModified() returned " + modifyTime);
			
			passed = modifyTime == 0;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests lastModified() on a directory (modification date is NOT supported by filesystem)", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:24,代码来源:LastModified.java

示例9: startApp

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
public void startApp() {
    System.out.println("START - Background alarm started: " + startedBackgroundAlarm());

    receiveSMS();

    try {
        FileConnection file = (FileConnection)Connector.open("file:////startBackgroundService");
        if (!file.exists()) {
            file.create();
        }
        file.close();
    } catch (IOException e) {
        System.out.println("Unexpected exception: " + e);
        return;
    }

    System.out.println("DONE - Background alarm started: " + startedBackgroundAlarm());
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:ForegroundEnableBackgroundServiceMIDlet.java

示例10: test0001

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests canWrite() on a writable file
 */
public void test0001() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			addOperationDesc("Setting file as writable");
			conn.setWritable(true);
			
			boolean canWrite = conn.canWrite();
			addOperationDesc("canWrite() returned " + canWrite);
			
			passed = canWrite==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests canWrite() on a writable file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:CanWrite.java

示例11: test0002

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests canWrite() on a non-writable file
 */
public void test0002() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			addOperationDesc("Setting file as non-writable");
			conn.setWritable(false);
			
			boolean canWrite = conn.canWrite();
			addOperationDesc("canWrite() returned " + canWrite);
			
			passed = canWrite==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests canWrite() on a non-writable file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:CanWrite.java

示例12: test0003

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests canWrite() on a writable directory
 */
public void test0003() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating directory: " + conn.getURL());
			ensureDirExists(conn);
			
			addOperationDesc("Setting directory as writable");
			conn.setWritable(true);
			
			boolean canWrite = conn.canWrite();
			addOperationDesc("canWrite() returned " + canWrite);
			
			passed = canWrite==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests canWrite() on a writable directory", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:CanWrite.java

示例13: test0004

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests canWrite() on a non-writable directory
 */
public void test0004() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating directory: " + conn.getURL());
			ensureDirExists(conn);
			
			addOperationDesc("Setting directory as non-writable");
			conn.setWritable(false);
			
			boolean canWrite = conn.canWrite();
			addOperationDesc("canWrite() returned " + canWrite);
			
			passed = canWrite==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests canWrite() on a on-writable directory", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:CanWrite.java

示例14: test0005

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests canWrite() on a file (writable attribute is NOT supported by filesystem)
 */
public void test0005() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			addOperationDesc("Setting file as non-writable");
			conn.setWritable(false);
			
			boolean canWrite = conn.canWrite();
			addOperationDesc("canWrite() returned " + canWrite);
			
			passed = canWrite==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests canWrite() on a file (writable attribute is NOT supported by filesystem)", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:CanWrite.java

示例15: test0006

import javax.microedition.io.file.FileConnection; //导入依赖的package包/类
/**
 * Tests canWrite() on a directory (writable attribute is NOT supported by filesystem)
 */
public void test0006() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating directory: " + conn.getURL());
			ensureDirExists(conn);
			
			addOperationDesc("Setting directory as non-writable");
			conn.setWritable(false);
			
			boolean canWrite = conn.canWrite();
			addOperationDesc("canWrite() returned " + canWrite);
			
			passed = canWrite==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests canWrite() on a directory (writable attribute is NOT supported by filesystem)", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:CanWrite.java


注:本文中的javax.microedition.io.file.FileConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。