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


Java FileConnection.openInputStream方法代码示例

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


在下文中一共展示了FileConnection.openInputStream方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: openInputStream

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public InputStream openInputStream(Object connection) throws IOException {
    if(connection instanceof String) {
        FileConnection fc = (FileConnection)Connector.open((String)connection, Connector.READ);
        BufferedInputStream o = new BufferedInputStream(fc.openInputStream(), (String)connection);
        o.setConnection(fc);
        return o;
    }
    return new BufferedInputStream(((HttpConnection)connection).openInputStream(), ((HttpConnection)connection).getURL());
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:13,代码来源:GameCanvasImplementation.java

示例4: openInputStream

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public InputStream openInputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        FileConnection fc = (FileConnection) Connector.open((String) connection, Connector.READ);
        BufferedInputStream o = new BufferedInputStream(fc.openInputStream(), (String) connection);
        o.setConnection(fc);
        return o;
    }
    return new BufferedInputStream(((HttpConnection) connection).openInputStream(), ((HttpConnection) connection).getURL());
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:13,代码来源:BlackBerryImplementation.java

示例5: runBenchmark

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
void runBenchmark() {
    try {
        long start;

        String dirPath = System.getProperty("fileconn.dir.private");
        FileConnection file = (FileConnection)Connector.open(dirPath + "test");
        if (file.exists()) {
            file.delete();
        }
        file.create();

        OutputStream fileOut = file.openOutputStream();
        start = JVM.monotonicTimeMillis();
        writeUTF(fileOut);
        System.out.println("DataOutputStream::writeUTF in file: " + (JVM.monotonicTimeMillis() - start));

        InputStream fileIn = file.openInputStream();
        start = JVM.monotonicTimeMillis();
        readUTF(fileIn);
        System.out.println("DataInputStream::readUTF from file: " + (JVM.monotonicTimeMillis() - start));

        file.close();
    } catch (IOException e) {
        System.out.println("Unexpected exception: " + e);
        e.printStackTrace();
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:28,代码来源:DataInputOutputStreamFileBench.java

示例6: test0001

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests openInputStream()
 */
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);
			
			InputStream is = null;
			OutputStream os = null;
			try {
				addOperationDesc("Writing byte to output stream: 69");
				os = conn.openOutputStream();
				os.write(69);
				os.flush();
				
				is = conn.openInputStream();
				int result = is.read();
				addOperationDesc("Reading byte from input stream: " + result);
				
				passed = result==69;
			} finally {
				if (is != null) is.close();
				if (os != null) os.close();
			}
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests openInputStream()", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:39,代码来源:OpenInputStream.java

示例7: test0007

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Streams can be opened and closed more than once on a connection
 */
public void test0007() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		InputStream stream = null;
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			addOperationDesc("Opening stream");
			stream = conn.openInputStream();
			addOperationDesc("Closing stream");
			stream.close();
			stream = null;
			
			addOperationDesc("Opening stream");
			stream = conn.openInputStream();
			addOperationDesc("Closing stream");
			stream.close();
			stream = null;
			
			passed = true;
		} finally {
			if (stream!=null) stream.close();
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Streams can be opened and closed more than once on a connection", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:37,代码来源:OpenInputStream.java

示例8: read

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public static byte[] read(String path) {
    try {
        FileConnection fc = (FileConnection) Connector.open(path, Connector.READ);

        InputStream in = fc.openInputStream();
        byte[] imageBytes = new byte[(int) fc.fileSize()];
        in.read(imageBytes);
        in.close();
        fc.close();

        return imageBytes;
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:16,代码来源:DeviceMemory.java

示例9: test

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public void test(TestHarness th) {
    try {
        FileConnection file = (FileConnection)Connector.open("file:////prova");
        if (file.exists()) {
            file.delete();
        }
        file.create();

        RandomAccessStream ras = new RandomAccessStream();
        ras.connect("prova", Connector.READ_WRITE);

        OutputStream out = ras.openOutputStream();

        testWrite(th, out);

        out.close();

        ras.setPosition(0);

        InputStream in = ras.openInputStream();

        testRead(th, in);

        in.close();

        ras.disconnect();

        file.delete();
        th.check(!file.exists());
        file.create();

        out = file.openOutputStream();
        testWrite(th, out);
        out.close();
        in = file.openInputStream();
        testRead(th, in);
        in.close();

        file.delete();
        file.close();
    } catch (Exception e) {
        th.fail("Unexpected exception: " + e);
        e.printStackTrace();
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:46,代码来源:TestInputOutputStorage.java


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