適用於 Adobe® Flash® Platform 的 ActionScript® 3.0 參考
首頁  |  隱藏套件和類別清單 |  套件  |  類別  |  新增內容  |  索引  |  附錄  |  為什麼顯示英文?
篩選: AIR 30.0 和更早版本, Flash Player 30.0 和更早版本, Flash Lite 4
Flex 4.6 和更早版本, Flash Pro CS6 和更早版本
隱藏篩選
flash.filesystem 

FileStream  - AS3

套件x

最上層
adobe.utils
air.desktop
air.net
air.update
air.update.events
coldfusion.air
coldfusion.air.errors
coldfusion.air.events
coldfusion.service
coldfusion.service.events
coldfusion.service.mxml
com.adobe.acm.solutions.authoring.domain.extensions
com.adobe.acm.solutions.ccr.domain.extensions
com.adobe.consulting.pst.vo
com.adobe.dct.component
com.adobe.dct.component.datadictionary
com.adobe.dct.component.datadictionaryElement
com.adobe.dct.component.dataElementsPanel
com.adobe.dct.component.toolbars
com.adobe.dct.event
com.adobe.dct.exp
com.adobe.dct.model
com.adobe.dct.service
com.adobe.dct.service.provider
com.adobe.dct.transfer
com.adobe.dct.util
com.adobe.dct.view
com.adobe.ep.taskmanagement.domain
com.adobe.ep.taskmanagement.event
com.adobe.ep.taskmanagement.filter
com.adobe.ep.taskmanagement.services
com.adobe.ep.taskmanagement.util
com.adobe.ep.ux.attachmentlist.component
com.adobe.ep.ux.attachmentlist.domain
com.adobe.ep.ux.attachmentlist.domain.events
com.adobe.ep.ux.attachmentlist.domain.renderers
com.adobe.ep.ux.attachmentlist.skin
com.adobe.ep.ux.attachmentlist.skin.renderers
com.adobe.ep.ux.content.event
com.adobe.ep.ux.content.factory
com.adobe.ep.ux.content.handlers
com.adobe.ep.ux.content.managers
com.adobe.ep.ux.content.model.asset
com.adobe.ep.ux.content.model.preview
com.adobe.ep.ux.content.model.relation
com.adobe.ep.ux.content.model.search
com.adobe.ep.ux.content.model.toolbar
com.adobe.ep.ux.content.search
com.adobe.ep.ux.content.services
com.adobe.ep.ux.content.services.load
com.adobe.ep.ux.content.services.permissions
com.adobe.ep.ux.content.services.preview
com.adobe.ep.ux.content.services.providers
com.adobe.ep.ux.content.services.query
com.adobe.ep.ux.content.services.relationships
com.adobe.ep.ux.content.services.search.lccontent
com.adobe.ep.ux.content.services.version
com.adobe.ep.ux.content.view
com.adobe.ep.ux.content.view.components.activate
com.adobe.ep.ux.content.view.components.grid
com.adobe.ep.ux.content.view.components.grid.hover
com.adobe.ep.ux.content.view.components.grid.hover.component
com.adobe.ep.ux.content.view.components.grid.renderers
com.adobe.ep.ux.content.view.components.relationships
com.adobe.ep.ux.content.view.components.review
com.adobe.ep.ux.content.view.components.search.renderers
com.adobe.ep.ux.content.view.components.searchpod
com.adobe.ep.ux.content.view.components.toolbar
com.adobe.ep.ux.content.view.components.toolbar.controlRenderers
com.adobe.ep.ux.content.view.components.version
com.adobe.ep.ux.documentsubmit.component
com.adobe.ep.ux.documentsubmit.domain
com.adobe.ep.ux.documentsubmit.skin
com.adobe.ep.ux.taskaction.component
com.adobe.ep.ux.taskaction.domain
com.adobe.ep.ux.taskaction.domain.events
com.adobe.ep.ux.taskaction.skin
com.adobe.ep.ux.taskdetails.component
com.adobe.ep.ux.taskdetails.domain
com.adobe.ep.ux.taskdetails.skin
com.adobe.ep.ux.tasklist.component
com.adobe.ep.ux.tasklist.domain
com.adobe.ep.ux.tasklist.skin
com.adobe.ep.ux.webdocumentviewer.domain
com.adobe.exm.expression
com.adobe.exm.expression.error
com.adobe.exm.expression.event
com.adobe.exm.expression.impl
com.adobe.fiber.runtime.lib
com.adobe.fiber.services
com.adobe.fiber.services.wrapper
com.adobe.fiber.styles
com.adobe.fiber.util
com.adobe.fiber.valueobjects
com.adobe.gravity.binding
com.adobe.gravity.context
com.adobe.gravity.flex.bundleloader
com.adobe.gravity.flex.progress
com.adobe.gravity.flex.serviceloader
com.adobe.gravity.framework
com.adobe.gravity.init
com.adobe.gravity.service.bundleloader
com.adobe.gravity.service.logging
com.adobe.gravity.service.manifest
com.adobe.gravity.service.progress
com.adobe.gravity.tracker
com.adobe.gravity.ui
com.adobe.gravity.utility
com.adobe.gravity.utility.async
com.adobe.gravity.utility.error
com.adobe.gravity.utility.events
com.adobe.gravity.utility.factory
com.adobe.gravity.utility.flex.async
com.adobe.gravity.utility.logging
com.adobe.gravity.utility.message
com.adobe.gravity.utility.sequence
com.adobe.gravity.utility.url
com.adobe.guides.control
com.adobe.guides.domain
com.adobe.guides.i18n
com.adobe.guides.spark.components.skins
com.adobe.guides.spark.components.skins.mx
com.adobe.guides.spark.headers.components
com.adobe.guides.spark.headers.skins
com.adobe.guides.spark.layouts.components
com.adobe.guides.spark.layouts.skins
com.adobe.guides.spark.navigators.components
com.adobe.guides.spark.navigators.renderers
com.adobe.guides.spark.navigators.skins
com.adobe.guides.spark.util
com.adobe.guides.spark.wrappers.components
com.adobe.guides.spark.wrappers.skins
com.adobe.guides.submit
com.adobe.icc.dc.domain
com.adobe.icc.dc.domain.factory
com.adobe.icc.editors.events
com.adobe.icc.editors.handlers
com.adobe.icc.editors.managers
com.adobe.icc.editors.model
com.adobe.icc.editors.model.config
com.adobe.icc.editors.model.el
com.adobe.icc.editors.model.el.operands
com.adobe.icc.editors.model.el.operators
com.adobe.icc.enum
com.adobe.icc.external.dc
com.adobe.icc.obj
com.adobe.icc.services
com.adobe.icc.services.category
com.adobe.icc.services.config
com.adobe.icc.services.download
com.adobe.icc.services.export
com.adobe.icc.services.external
com.adobe.icc.services.formbridge
com.adobe.icc.services.fragmentlayout
com.adobe.icc.services.layout
com.adobe.icc.services.letter
com.adobe.icc.services.locator
com.adobe.icc.services.module
com.adobe.icc.services.render
com.adobe.icc.services.submit
com.adobe.icc.services.user
com.adobe.icc.token
com.adobe.icc.vo
com.adobe.icc.vo.render
com.adobe.icomm.assetplacement.controller
com.adobe.icomm.assetplacement.controller.utils
com.adobe.icomm.assetplacement.data
com.adobe.icomm.assetplacement.model
com.adobe.livecycle.assetmanager.client
com.adobe.livecycle.assetmanager.client.event
com.adobe.livecycle.assetmanager.client.handler
com.adobe.livecycle.assetmanager.client.managers
com.adobe.livecycle.assetmanager.client.model
com.adobe.livecycle.assetmanager.client.model.cms
com.adobe.livecycle.assetmanager.client.service
com.adobe.livecycle.assetmanager.client.service.search
com.adobe.livecycle.assetmanager.client.service.search.cms
com.adobe.livecycle.assetmanager.client.utils
com.adobe.livecycle.content
com.adobe.livecycle.rca.model
com.adobe.livecycle.rca.model.constant
com.adobe.livecycle.rca.model.document
com.adobe.livecycle.rca.model.participant
com.adobe.livecycle.rca.model.reminder
com.adobe.livecycle.rca.model.stage
com.adobe.livecycle.rca.service
com.adobe.livecycle.rca.service.core
com.adobe.livecycle.rca.service.core.delegate
com.adobe.livecycle.rca.service.process
com.adobe.livecycle.rca.service.process.delegate
com.adobe.livecycle.rca.token
com.adobe.livecycle.ria.security.api
com.adobe.livecycle.ria.security.service
com.adobe.mosaic.layouts
com.adobe.mosaic.layouts.dragAndDrop
com.adobe.mosaic.layouts.interfaces
com.adobe.mosaic.mxml
com.adobe.mosaic.om.constants
com.adobe.mosaic.om.events
com.adobe.mosaic.om.impl
com.adobe.mosaic.om.interfaces
com.adobe.mosaic.skinning
com.adobe.mosaic.sparklib.editors
com.adobe.mosaic.sparklib.optionMenu
com.adobe.mosaic.sparklib.scrollableMenu
com.adobe.mosaic.sparklib.scrollableMenu.skins
com.adobe.mosaic.sparklib.tabLayout
com.adobe.mosaic.sparklib.tabLayout.events
com.adobe.mosaic.sparklib.tabLayout.layouts
com.adobe.mosaic.sparklib.tabLayout.skins
com.adobe.mosaic.sparklib.text
com.adobe.mosaic.sparklib.util
com.adobe.solutions.acm.authoring.presentation
com.adobe.solutions.acm.authoring.presentation.actionbar
com.adobe.solutions.acm.authoring.presentation.common
com.adobe.solutions.acm.authoring.presentation.events
com.adobe.solutions.acm.authoring.presentation.fragment
com.adobe.solutions.acm.authoring.presentation.letter
com.adobe.solutions.acm.authoring.presentation.letter.data
com.adobe.solutions.acm.authoring.presentation.preview
com.adobe.solutions.acm.authoring.presentation.rte
com.adobe.solutions.acm.ccr.presentation
com.adobe.solutions.acm.ccr.presentation.contentcapture
com.adobe.solutions.acm.ccr.presentation.contentcapture.events
com.adobe.solutions.acm.ccr.presentation.contentcapture.preview
com.adobe.solutions.acm.ccr.presentation.datacapture
com.adobe.solutions.acm.ccr.presentation.datacapture.renderers
com.adobe.solutions.acm.ccr.presentation.pdf
com.adobe.solutions.exm
com.adobe.solutions.exm.authoring
com.adobe.solutions.exm.authoring.components.controls
com.adobe.solutions.exm.authoring.components.toolbars
com.adobe.solutions.exm.authoring.domain
com.adobe.solutions.exm.authoring.domain.expression
com.adobe.solutions.exm.authoring.domain.impl
com.adobe.solutions.exm.authoring.domain.method
com.adobe.solutions.exm.authoring.domain.variable
com.adobe.solutions.exm.authoring.enum
com.adobe.solutions.exm.authoring.events
com.adobe.solutions.exm.authoring.model
com.adobe.solutions.exm.authoring.renderer
com.adobe.solutions.exm.authoring.view
com.adobe.solutions.exm.expression
com.adobe.solutions.exm.impl
com.adobe.solutions.exm.impl.method
com.adobe.solutions.exm.method
com.adobe.solutions.exm.mock
com.adobe.solutions.exm.mock.method
com.adobe.solutions.exm.runtime
com.adobe.solutions.exm.runtime.impl
com.adobe.solutions.exm.variable
com.adobe.solutions.prm.constant
com.adobe.solutions.prm.domain
com.adobe.solutions.prm.domain.factory
com.adobe.solutions.prm.domain.impl
com.adobe.solutions.prm.domain.manager
com.adobe.solutions.prm.presentation.asset
com.adobe.solutions.prm.presentation.constant
com.adobe.solutions.prm.presentation.document
com.adobe.solutions.prm.presentation.event
com.adobe.solutions.prm.presentation.file
com.adobe.solutions.prm.presentation.project
com.adobe.solutions.prm.presentation.team
com.adobe.solutions.prm.presentation.util
com.adobe.solutions.prm.service
com.adobe.solutions.prm.services.impl
com.adobe.solutions.prm.vo
com.adobe.solutions.rca.constant
com.adobe.solutions.rca.domain
com.adobe.solutions.rca.domain.common
com.adobe.solutions.rca.domain.factory
com.adobe.solutions.rca.domain.impl
com.adobe.solutions.rca.domain.impl.manager
com.adobe.solutions.rca.domain.manager
com.adobe.solutions.rca.presentation
com.adobe.solutions.rca.presentation.comment
com.adobe.solutions.rca.presentation.constant
com.adobe.solutions.rca.presentation.event
com.adobe.solutions.rca.presentation.gantt
com.adobe.solutions.rca.presentation.gantt.ruler
com.adobe.solutions.rca.presentation.template
com.adobe.solutions.rca.presentation.template.audit
com.adobe.solutions.rca.presentation.template.definition
com.adobe.solutions.rca.presentation.template.documents
com.adobe.solutions.rca.presentation.template.stages
com.adobe.solutions.rca.presentation.util
com.adobe.solutions.rca.service
com.adobe.solutions.rca.services.impl
com.adobe.solutions.rca.vo
com.adobe.solutions.rca.vo.um
com.adobe.viewsource
fl.accessibility
fl.containers
fl.controls
fl.controls.dataGridClasses
fl.controls.listClasses
fl.controls.progressBarClasses
fl.core
fl.data
fl.display
fl.events
fl.ik
fl.lang
fl.livepreview
fl.managers
fl.motion
fl.motion.easing
fl.rsl
fl.text
fl.transitions
fl.transitions.easing
fl.video
flash.accessibility
flash.concurrent
flash.crypto
flash.data
flash.desktop
flash.display
flash.display3D
flash.display3D.textures
flash.errors
flash.events
flash.external
flash.filesystem
flash.filters
flash.geom
flash.globalization
flash.html
flash.media
flash.net
flash.net.dns
flash.net.drm
flash.notifications
flash.permissions
flash.printing
flash.profiler
flash.sampler
flash.security
flash.sensors
flash.system
flash.text
flash.text.engine
flash.text.ime
flash.ui
flash.utils
flash.xml
flashx.textLayout
flashx.textLayout.compose
flashx.textLayout.container
flashx.textLayout.conversion
flashx.textLayout.edit
flashx.textLayout.elements
flashx.textLayout.events
flashx.textLayout.factory
flashx.textLayout.formats
flashx.textLayout.operations
flashx.textLayout.utils
flashx.undo
ga.controls
ga.layouts
ga.model
ga.uiComponents
ga.util
ga.views
ga.wrappers
lc.foundation
lc.foundation.domain
lc.foundation.events
lc.foundation.ui
lc.foundation.util
lc.preloader
lc.procmgmt
lc.procmgmt.commands
lc.procmgmt.domain
lc.procmgmt.events
lc.procmgmt.formbridge
lc.procmgmt.impl
lc.procmgmt.ui.attachments
lc.procmgmt.ui.controls
lc.procmgmt.ui.controls.card
lc.procmgmt.ui.controls.renderer
lc.procmgmt.ui.help
lc.procmgmt.ui.layout
lc.procmgmt.ui.presentationmodel
lc.procmgmt.ui.process
lc.procmgmt.ui.search
lc.procmgmt.ui.startpoint
lc.procmgmt.ui.task
lc.procmgmt.ui.task.form
lc.procmgmt.ui.task.form.commands
lc.procmgmt.ui.tracking
mx.accessibility
mx.automation
mx.automation.air
mx.automation.delegates
mx.automation.delegates.advancedDataGrid
mx.automation.delegates.charts
mx.automation.delegates.containers
mx.automation.delegates.controls
mx.automation.delegates.controls.dataGridClasses
mx.automation.delegates.controls.fileSystemClasses
mx.automation.delegates.core
mx.automation.delegates.flashflexkit
mx.automation.events
mx.binding
mx.binding.utils
mx.charts
mx.charts.chartClasses
mx.charts.effects
mx.charts.effects.effectClasses
mx.charts.events
mx.charts.renderers
mx.charts.series
mx.charts.series.items
mx.charts.series.renderData
mx.charts.styles
mx.collections
mx.collections.errors
mx.containers
mx.containers.accordionClasses
mx.containers.dividedBoxClasses
mx.containers.errors
mx.containers.utilityClasses
mx.controls
mx.controls.advancedDataGridClasses
mx.controls.dataGridClasses
mx.controls.listClasses
mx.controls.menuClasses
mx.controls.olapDataGridClasses
mx.controls.scrollClasses
mx.controls.sliderClasses
mx.controls.textClasses
mx.controls.treeClasses
mx.controls.videoClasses
mx.core
mx.core.windowClasses
mx.data
mx.data.crypto
mx.data.errors
mx.data.events
mx.data.messages
mx.data.mxml
mx.data.offline.errors
mx.data.utils
mx.effects
mx.effects.easing
mx.effects.effectClasses
mx.events
mx.filters
mx.flash
mx.formatters
mx.geom
mx.graphics
mx.graphics.codec
mx.graphics.shaderClasses
mx.logging
mx.logging.errors
mx.logging.targets
mx.managers
mx.messaging
mx.messaging.channels
mx.messaging.config
mx.messaging.errors
mx.messaging.events
mx.messaging.management
mx.messaging.messages
mx.modules
mx.netmon
mx.olap
mx.olap.aggregators
mx.preloaders
mx.printing
mx.resources
mx.rpc
mx.rpc.events
mx.rpc.http
mx.rpc.http.mxml
mx.rpc.livecycle
mx.rpc.mxml
mx.rpc.remoting
mx.rpc.remoting.mxml
mx.rpc.soap
mx.rpc.soap.mxml
mx.rpc.wsdl
mx.rpc.xml
mx.skins
mx.skins.halo
mx.skins.spark
mx.skins.wireframe
mx.skins.wireframe.windowChrome
mx.states
mx.styles
mx.utils
mx.validators
org.osmf.containers
org.osmf.display
org.osmf.elements
org.osmf.events
org.osmf.layout
org.osmf.logging
org.osmf.media
org.osmf.metadata
org.osmf.net
org.osmf.net.dvr
org.osmf.net.httpstreaming
org.osmf.net.metrics
org.osmf.net.qos
org.osmf.net.rtmpstreaming
org.osmf.net.rules
org.osmf.traits
org.osmf.utils
spark.accessibility
spark.automation.delegates
spark.automation.delegates.components
spark.automation.delegates.components.gridClasses
spark.automation.delegates.components.mediaClasses
spark.automation.delegates.components.supportClasses
spark.automation.delegates.skins.spark
spark.automation.events
spark.collections
spark.components
spark.components.calendarClasses
spark.components.gridClasses
spark.components.mediaClasses
spark.components.supportClasses
spark.components.windowClasses
spark.core
spark.effects
spark.effects.animation
spark.effects.easing
spark.effects.interpolation
spark.effects.supportClasses
spark.events
spark.filters
spark.formatters
spark.formatters.supportClasses
spark.globalization
spark.globalization.supportClasses
spark.layouts
spark.layouts.supportClasses
spark.managers
spark.modules
spark.preloaders
spark.primitives
spark.primitives.supportClasses
spark.skins
spark.skins.mobile
spark.skins.mobile.supportClasses
spark.skins.spark
spark.skins.spark.mediaClasses.fullScreen
spark.skins.spark.mediaClasses.normal
spark.skins.spark.windowChrome
spark.skins.wireframe
spark.skins.wireframe.mediaClasses
spark.skins.wireframe.mediaClasses.fullScreen
spark.transitions
spark.utils
spark.validators
spark.validators.supportClasses
xd.core.axm.enterprise.view.components
xd.core.axm.enterprise.view.skins
xd.core.axm.view.components
xd.core.axm.view.components.support

語言元素

全域常數
全域函數
運算子
陳述式、關鍵字和指令
特殊類型

附錄

新增內容
編譯器錯誤
編譯器警告
執行階段錯誤
移轉至 ActionScript 3
支援的字元集
僅限 MXML 標籤
移動 XML 元素
Timed Text 標籤
不建議元素清單
AccessibilityImplementation 常數
如何使用 ActionScript 範例
法律聲明
套件flash.filesystem
類別public class FileStream
繼承FileStream Inheritance EventDispatcher Inheritance Object
實作 IDataInput, IDataOutput

執行階段版本: AIR 1.0

FileStream 物件可用來讀取及寫入檔案。檔案可以藉由呼叫 open() 方法以同步方式開啟,或藉由呼叫 openAsync() 方法以非同步方式開啟。

以非同步方式開啟檔案的好處是當 Adobe AIR 在背景中執行讀取及寫入程序時,可以執行其他程式碼。以非同步方式開啟時,當作業進行時會傳送 progress 事件。

以同步方式所開啟之 File 物件的行為就像 ByteArray 物件;以非同步方式所開啟之檔案的行為就像 Socket 或 URLStream 物件。當 File 物件以同步方式開啟時,呼叫者會在基礎檔案中讀取或寫入要求的資料時暫停。以非同步方式開啟時,任何寫入串流的資料會立即進行緩衝,並在稍後寫入檔案。

無論以同步或非同步方式從檔案讀取,實際的讀取方法都是同步的。在這兩種案例中,都會讀取目前「可用」的資料。不同之處在於,以同步方式讀取時,所有資料隨時都可供使用,而以非同步方式讀取時,資料會隨著資料串流至讀取緩衝區而漸漸變得可用。無論如何,在目前時刻可以透過同步方式讀取的資料是由 bytesAvailable 屬性表示。

處理非同步輸入的應用程式通常會註冊 progress 事件,並在資料變得可用時藉由呼叫讀取方法使用資料。或者,應用程式也可以註冊 complete 事件等待所有資料可用,並在 complete 事件傳送時處理整個資料集。



公用屬性
 屬性定義自
      bytesAvailable : uint
[唯讀] 會傳回可在輸入緩衝區中讀取之資料的位元組數。
FileStream
 Inheritedconstructor : Object
類別物件的參照或是特定物件實體的建構函數。
Object
      endian : String
資料的位元組順序,會是 Endian 類別的 BIG_ENDIAN 或 LITTLE_ENDIAN 常數。
FileStream
      objectEncoding : uint
指定當使用 readObject() 或 writeObject() 方法來寫入或讀取二進位資料時,要使用 AMF3 或 AMF0 格式。
FileStream
      position : Number
檔案中目前的位置。
FileStream
      readAhead : Number
非同步讀取檔案時,從磁碟讀取的最小資料量。
FileStream
公用方法
 方法定義自
  
    FileStream()
建立 FileStream 物件。
FileStream
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。
EventDispatcher
  
    close():void
關閉 FileStream 物件。
FileStream
 Inherited
會將事件傳送到事件流程。
EventDispatcher
 Inherited
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。
EventDispatcher
 Inherited
指出物件是否有已定義的指定屬性。
Object
 Inherited
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。
Object
  
    open(file:File, fileMode:String):void
以同步方式開啟 FileStream 物件,並指向 file 參數所指定的檔案。
FileStream
  
    openAsync(file:File, fileMode:String):void
以非同步方式開啟 FileStream 物件,並指向 file 參數所指定的檔案。
FileStream
 Inherited
指出指定的屬性是否存在,以及是否可列舉。
Object
  
會從檔案串流、位元組串流或位元組陣列讀取 Boolean 值。
FileStream
  
    readByte():int
會從檔案串流、位元組串流或位元組陣列讀取具有正負號的位元組。
FileStream
  
    readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
從檔案串流、位元組串流或位元組陣列,讀取 length 參數所指定的資料位元組數目。
FileStream
  
    readDouble():Number
會從檔案串流、位元組串流或位元組陣列讀取 IEEE 754 雙精度浮點數。
FileStream
  
    readFloat():Number
會從檔案串流、位元組串流或位元組陣列讀取 IEEE 754 單精度浮點數。
FileStream
  
    readInt():int
會從檔案串流、位元組串流或位元組陣列讀取具有正負號的 32 位元整數。
FileStream
  
    readMultiByte(length:uint, charSet:String):String
使用指定的字元集,從檔案串流、位元組串流或位元組陣列讀取指定長度的多位元組字串。
FileStream
  
    readObject():*
從檔案串流、位元組串流或位元組陣列讀取物件並以 AMF 序列化格式編碼。
FileStream
  
    readShort():int
會從檔案串流、位元組串流或位元組陣列讀取具有正負號的 16 位元整數。
FileStream
  
會從檔案串流、位元組串流或位元組陣列讀取無正負號的位元組。
FileStream
  
會從檔案串流、位元組串流或位元組陣列讀取無正負號的 32 位元整數。
FileStream
  
會從檔案串流、位元組串流或位元組陣列讀取無正負號的 16 位元整數。
FileStream
  
    readUTF():String
從檔案串流、位元組串流或位元組陣列讀取 UTF-8 字串。
FileStream
  
    readUTFBytes(length:uint):String
從位元組串流或位元組陣列讀取 UTF-8 位元組的序列,並傳回字串。
FileStream
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
會從 EventDispatcher 物件移除偵聽程式。
EventDispatcher
 Inherited
為迴圈作業設定動態屬性的可用性。
Object
 Inherited
傳回代表此物件的字串,根據地區特定慣例進行格式化。
Object
 Inherited
會傳回指定之物件的字串形式。
Object
  
    truncate():void
在 FileStream 物件的 position 屬性所指定的位置上截斷檔案。
FileStream
 Inherited
會傳回指定之物件的基本值。
Object
 Inherited
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。
EventDispatcher
  
    writeBoolean(value:Boolean):void
會寫入 Boolean 值。
FileStream
  
    writeByte(value:int):void
會寫入位元組。
FileStream
  
    writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void
以 length 指定的長度,從指定的位元組陣列 bytes,將位元組序列從 offset 所指定的位元組 (使用從零開始的索引) 開始寫入檔案串流、位元組串流或位元組陣列。
FileStream
  
    writeDouble(value:Number):void
會寫入 IEEE 754 雙精度 (64 位元) 浮點數。
FileStream
  
    writeFloat(value:Number):void
會寫入 IEEE 754 單精度 (32 位元) 浮點數。
FileStream
  
    writeInt(value:int):void
會寫入 32 位元的具有正負號整數。
FileStream
  
    writeMultiByte(value:String, charSet:String):void
使用指定的字元集,將多位元組字串寫入檔案串流、位元組串流或位元組陣列。
FileStream
  
    writeObject(object:*):void
使用 AMF 序列化格式,將物件寫入檔案串流、位元組串流或位元組陣列。
FileStream
  
    writeShort(value:int):void
會寫入 16 位元整數。
FileStream
  
    writeUnsignedInt(value:uint):void
會寫入 32 位元的無正負號整數。
FileStream
  
    writeUTF(value:String):void
將 UTF-8 字串寫入檔案串流、位元組串流或位元組陣列。
FileStream
  
    writeUTFBytes(value:String):void
會寫入 UTF-8 字串。
FileStream
事件
 事件 摘要 定義自
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式取得作業系統焦點並成為作用中時傳送。EventDispatcher
  
    close
表示已藉由明確呼叫 close() 方法關閉串流。FileStream
  
    complete
指出已到達串流結尾。FileStream
 Inherited[廣播事件] 當 Flash Player 或 AIR 應用程式失去作業系統焦點並成為非作用中時傳送。EventDispatcher
  
    ioError
表示非同步檔案 I/O 作業期間發生錯誤。FileStream
  指出緩衝資料已寫入檔案。FileStream
  
    progress
指出串流上新資料的可用性。FileStream
屬性詳細資訊
    

bytesAvailable

屬性
bytesAvailable:uint  [唯讀]

執行階段版本: AIR 1.0

會傳回可在輸入緩衝區中讀取之資料的位元組數。 使用者程式碼必須呼叫 bytesAvailable,確定在嘗試以其中一種讀取方法進行讀取之前,具有足夠的資料。



實作
    public function get bytesAvailable():uint
    

endian

屬性 
endian:String

執行階段版本: AIR 1.0

資料的位元組順序,會是 Endian 類別的 BIG_ENDIANLITTLE_ENDIAN 常數。



實作
    public function get endian():String
    public function set endian(value:String):void
    

objectEncoding

屬性 
objectEncoding:uint

執行階段版本: AIR 1.0

指定當使用 readObject()writeObject() 方法來寫入或讀取二進位資料時,要使用 AMF3 或 AMF0 格式。

此值是來自於 ObjectEncoding 類別的常數。根據預設會使用 AMF3 格式。



實作
    public function get objectEncoding():uint
    public function set objectEncoding(value:uint):void

相關 API 元素

    

position

屬性 
position:Number

執行階段版本: AIR 1.0

檔案中目前的位置。

以下列任何方式修改此值:

  • 當您明確設定屬性時
  • 當讀取 FileStream 物件時 (使用其中一個讀取方法)
  • 當寫入 FileStream 物件時

位置定義為 Number (而非單位),以便支援大於 232 位元組長度的檔案。這個屬性的值一定是小於 253 的整數。如果您將此值設定為分數,則會將值無條件捨去為最接近的整數。

以非同步方式讀取檔案時,如果您設定 position 屬性,則應用程式會以指定位置開始的資料來開始填滿讀取緩衝區,而且 bytesAvailable 屬性可以設定為 0。請等待 complete 事件出現,接著使用讀取方法讀取資料,或是等待 progress 事件並檢查 bytesAvailable 屬性,才使用讀取方法。



實作
    public function get position():Number
    public function set position(value:Number):void

範例  ( 如何使用本範例 )
下列程式碼示範 FileStream 物件的 position 屬性如何隨著應用程式從檔案讀取資料而更新。
import flash.fileSystem.*;
import flash.utils.ByteArray;
import flash.events.Event;

var sourceFile:File = File.documentsDirectory.resolvePath("Apollo Test/test.txt");
var stream:FileStream = new FileStream();
stream.addEventListener(Event.COMPLETE, readBytes);
stream.openAsync(sourceFile, FileMode.READ);

function readBytes(e:Event):void {
    var bytes:ByteArray = new ByteArray();
    trace("position 0:", stream.position); // 0
    bytes[0] = stream.readByte();
    trace("position 1:", stream.position); // 1
    fileStream.readBytes(bytes, stream.position, 4); 
    trace("position 2:", stream.position); // 5
    stream.close();
}
    

readAhead

屬性 
readAhead:Number

執行階段版本: AIR 1.0

非同步讀取檔案時,從磁碟讀取的最小資料量。

這個屬性會指定非同步串流嘗試從目前位置開始讀取的資料量。會根據檔案系統分頁大小,以區塊方式讀取資料。因此,若在 8KB (8192 位元組) 的電腦系統上將 readAhead 設定為 9,000,執行階段每次會預先讀取 2 個區塊,亦即 16384 個位元組。這個屬性的預設值為 infinity:根據預設,以非同步方式開啟並進行讀取的檔案會一直讀取至檔案結尾。

從讀取緩衝區中讀取資料,不會變更 readAhead 屬性值。當您從緩衝區中讀取資料時,會讀取新資料以重新填滿讀取緩衝區。

readAhead 屬性對以同步方式開啟的檔案沒有作用。

以非同步方式讀取資料時,FileStream 物件會傳送 progress 事件。在 progress 事件的事件處理常式方法中,檢查是否有所需的位元組數 (藉由檢查 bytesAvailable 屬性),然後使用讀取方法從讀取緩衝區中讀取資料。



實作
    public function get readAhead():Number
    public function set readAhead(value:Number):void

範例  ( 如何使用本範例 )
下列程式碼示範如何使用 readAhead 屬性將讀入檔案中的資料量限制為 100 個位元組:
import flash.filesystem.*;

var file:File = File.desktopDirectory.resolvePath("test.txt");
var fileStream:FileStream = new FileStream();
fileStream.readAhead = 100;
fileStream.addEventListener(ProgressEvent.PROGRESS, readProgressHandler)
fileStream.openAsync(file, FileMode.READ);
var results:ByteArray;

function readProgressHandler(event:ProgressEvent):void {
    if (fileStream.bytesAvailable >= 100) {
        fileStream.readBytes(results, 0, 100);
    }
}
建構函式詳細資料
    

FileStream

()建構函式
public function FileStream()

執行階段版本: AIR 1.0

建立 FileStream 物件。使用 open()openAsync() 方法開啟檔案。

相關 API 元素

方法詳細資訊

    close

()方法
public function close():void

執行階段版本: AIR 1.0

關閉 FileStream 物件。

在呼叫 close() 方法之後,您就無法讀取或寫入任何資料。如果檔案以非同步方式開啟 (FileStream 物件使用 openAsync() 方法開啟檔案),則呼叫 close() 方法會使物件傳送 close 事件。

自動關閉應用程式,也會關閉應用程式中與 FileStream 物件關聯的所有檔案。不過,在以非同步開啟且有待寫入資料的所有 FileStream 物件上,最好註冊 closed 事件,然後再關閉應用程式 (以確保資料寫入)。

您可以藉由呼叫 open()openAsync() 方法重複使用 FileStream 物件。這會關閉與 FileStream 物件關聯的任何檔案,但物件不會傳送 close 事件。

針對以非同步方式開啟的 FileStream 物件 (使用 openAsync() 方法),即使您為 FileStream 物件呼叫 close() 事件並刪除參考該物件的屬性和變數,只要有待處理的作業和待完成的已註冊事件處理常式,FileStream 物件就不會進行記憶體回收。尤其在下列任何狀況下,未參考的 FileStream 物件仍會存在:

  • 在檔案讀取作業中,尚未到達檔案結尾 (而且尚未傳送 complete 事件)。
  • 仍有要寫入的輸出資料,而且輸出相關事件 (如 outputProgress 事件或 ioError 事件) 有已註冊的事件偵聽程式。


事件
close:Event — 以非同步方式開啟的檔案已關閉。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會以「非同步」方式開啟 FileStream 物件,並將一個名為 test.txt 的文字檔寫入使用者文件目錄的 Apollo Test 子目錄中。呼叫 FileStream 物件的 close() 方法,會在資料寫入後關閉檔案。
import flash.filesystem.*;
import flash.events.Event;
            
var file:File = File.documentsDirectory;
file = file.resolvePath("Apollo Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.openAsync(file, FileMode.WRITE);
fileStream.writeUTFBytes("Hello");
fileStream.addEventListener(Event.CLOSE, fileClosed);
fileStream.close();

function fileClosed(event:Event):void {
    trace("closed");
}            

下列程式碼會以「同步」方式開啟 FileStream 物件,並將一個名為 test.txt 的文字檔寫入使用者文件目錄的 Apollo Test 子目錄中。呼叫 FileStream 物件的 close() 方法,會在資料寫入後關閉檔案。
import flash.filesystem.*;
            
var file:File = File.documentsDirectory;
file = file.resolvePath("Apollo Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeUTF("Hello");
fileStream.close();

    open

()方法 
public function open(file:File, fileMode:String):void

執行階段版本: AIR 1.0

以同步方式開啟 FileStream 物件,並指向 file 參數所指定的檔案。

如果 FileStream 物件已開啟,則呼叫此方法會在開啟之前先關閉檔案,而且不會針對先前開啟的檔案傳送進一步的事件 (包括 close)。

在支援檔案鎖定的系統上,以「寫入」或「更新」模式 (FileMode.WRITEFileMode.UPDATE) 開啟的檔案在關閉之前是不可讀取的。

一旦您完成對檔案執行的作業,請呼叫 FileStream 物件的 close() 方法。某些作業系統會限制可同時開啟的檔案數量。

參數

file:File — 指定要開啟之檔案的 File 物件。
 
fileMode:String — FileMode 類別中定義 FileStream 功能 (如讀取或寫入檔案的能力) 的字串。


擲回值
IOError — 檔案不存在;您沒有開啟檔案的適當權限;您開啟檔案來進行讀取存取,卻沒有讀取權限;或是您開啟檔案來進行寫入存取,卻沒有寫入權限。
 
SecurityError — 檔案位置位於應用程式目錄中,而且 fileMode 參數設定為「附加」、「更新」或「寫入」模式。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何以同步方式開啟使用者文件目錄 Apollo Test 子目錄中的 test.txt 檔案,然後使用系統字元集做為文字編碼,將檔案讀入字串。
import flash.filesystem.*;

var file:File = File.documentsDirectory;
file = file.resolvePath("Apollo Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.READ);
var str:String = fileStream.readMultiByte(file.size, File.systemCharset);
trace(str);
fileStream.close();

    openAsync

()方法 
public function openAsync(file:File, fileMode:String):void

執行階段版本: AIR 1.0

以非同步方式開啟 FileStream 物件,並指向 file 參數所指定的檔案。

如果 FileStream 物件已開啟,則呼叫此方法會在開啟之前先關閉檔案,而且不會針對先前開啟的檔案傳送進一步的事件 (包括 close)。

如果 fileMode 參數設定為 FileMode.READFileMode.UPDATE,一旦檔案開啟,AIR 就會將資料讀入輸入緩衝區,而且在資料讀入輸入緩衝區時會傳送 progressopen 事件。

在支援檔案鎖定的系統上,以「寫入」或「更新」模式 (FileMode.WRITEFileMode.UPDATE) 開啟的檔案在關閉之前是不可讀取的。

一旦您完成對檔案執行的作業,請呼叫 FileStream 物件的 close() 方法。某些作業系統會限制可同時開啟的檔案數量。

參數

file:File — 指定要開啟之檔案的 File 物件。
 
fileMode:String — FileMode 類別中定義 FileStream 功能 (如讀取或寫入檔案的能力) 的字串。


事件
ioError:IOErrorEvent — 檔案不存在;您沒有開啟檔案的適當權限;您開啟檔案來進行讀取存取,卻沒有讀取權限;或是您開啟檔案來進行寫入存取,卻沒有寫入權限。
 
progress:ProgressEvent — 當資料讀入輸入緩衝區時傳送 (檔案必須以設定為 FileMode.READFileMode.UPDATEfileMode 參數開啟。)
 
complete:Event — 檔案資料已讀入輸入緩衝區。(檔案必須以設定為 FileMode.READFileMode.UPDATEfileMode 參數開啟。)

擲回值
SecurityError — 檔案位置位於應用程式目錄中,而且 fileMode 參數設定為「附加」、「更新」或「寫入」模式。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼示範如何以非同步方式開啟使用者文件目錄 Apollo Test 子目錄中的 test.txt 檔案,然後使用系統字元集做為文字編碼,將檔案讀入字串。
import flash.filesystem.*;
import flash.events.Event;

var file:File = File.documentsDirectory;
file = file.resolvePath("Apollo Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.addEventListener(Event.COMPLETE, fileCompleteHandler)
fileStream.openAsync(file, FileMode.READ);

function fileCompleteHandler(event:Event):void {
    var str:String = fileStream.readMultiByte(fileStream.bytesAvailable, File.systemCharset);
    trace(str);
    fileStream.close();
}

    readBoolean

()方法 
public function readBoolean():Boolean

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取 Boolean 值。讀取單一位元組。若該位元組不為零,即傳回 true,否則傳回 false

傳回值
Boolean — Boolean 值,如果位元組不為零,則為 true,否則為 false

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readByte

()方法 
public function readByte():int

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取具有正負號的位元組。

傳回值
int — 傳回的值介於 -128 到 127 的範圍之間。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readBytes

()方法 
public function readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void

執行階段版本: AIR 1.0

從檔案串流、位元組串流或位元組陣列,讀取 length 參數所指定的資料位元組數目。這些位元組會讀入由 bytes 參數指定的 ByteArray 物件中,從 offset 所指定的位置開始。

參數

bytes:ByteArray — 要將資料讀入的 ByteArray 物件。
 
offset:uint (default = 0)bytes 參數中的偏移值,資料讀取應該會在此處開始。
 
length:uint (default = 0) — 要讀取的位元組數。 預設值為 0,會讀取所有可用的資料。


事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readDouble

()方法 
public function readDouble():Number

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取 IEEE 754 雙精度浮點數。

傳回值
Number — IEEE 754 雙精度浮點數。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readFloat

()方法 
public function readFloat():Number

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取 IEEE 754 單精度浮點數。

傳回值
Number — IEEE 754 單精度浮點數。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readInt

()方法 
public function readInt():int

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取具有正負號的 32 位元整數。

傳回值
int — 傳回的值介於 -2147483648 到 2147483647 的範圍之間。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readMultiByte

()方法 
public function readMultiByte(length:uint, charSet:String):String

執行階段版本: AIR 1.0

使用指定的字元集,從檔案串流、位元組串流或位元組陣列讀取指定長度的多位元組字串。

參數

length:uint — 所要讀取之位元組串流的位元組數。
 
charSet:String — 代表字元集之字串,該字元集用於解譯位元組。 可能的字元集字串包括 "shift-jis""cn-gb""iso-8859-1",以及其他等等。 如需完整清單,請參閱「支援的字元集」

注意:如果目前的系統沒有辦識出 charSet 參數的值,則 Adobe® Flash® Player 或 Adobe® AIR® 會使用系統的預設字碼頁當做字元集。例如,charSet 參數的值 (如同在 myTest.readMultiByte(22, "iso-8859-01")) 使用 01 取代 1 在您的開發系統上可能是可行的,但在其他系統可能不可行。在其他系統上,Flash Player 或 AIR 執行階段將會使用系統的預設字碼頁。

傳回值
String — UTF-8 編碼字串。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

相關 API 元素

    readObject

()方法 
public function readObject():*

執行階段版本: AIR 1.0

從檔案串流、位元組串流或位元組陣列讀取物件並以 AMF 序列化格式編碼。

傳回值
* — 經過還原序列化的物件

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

相關 API 元素

    readShort

()方法 
public function readShort():int

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取具有正負號的 16 位元整數。

傳回值
int — 傳回的值介於 -32768 到 32767 的範圍之間。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readUnsignedByte

()方法 
public function readUnsignedByte():uint

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取無正負號的位元組。

傳回值
uint — 傳回的值介於 0 到 255 的範圍之間。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readUnsignedInt

()方法 
public function readUnsignedInt():uint

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取無正負號的 32 位元整數。

傳回值
uint — 傳回的值介於 0 到 4294967295 的範圍之間。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readUnsignedShort

()方法 
public function readUnsignedShort():uint

執行階段版本: AIR 1.0

會從檔案串流、位元組串流或位元組陣列讀取無正負號的 16 位元整數。

傳回值
uint — 傳回的值介於 0 到 65535 的範圍之間。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readUTF

()方法 
public function readUTF():String

執行階段版本: AIR 1.0

從檔案串流、位元組串流或位元組陣列讀取 UTF-8 字串。會假定此字串的前置詞為無正負號的短整數,以指示以位元組為單位的長度。

這個方法類似於 Java® IDataInput 介面的 readUTF() 方法。

傳回值
String — 以位元組表示之字元所產生的 UTF-8 字串。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    readUTFBytes

()方法 
public function readUTFBytes(length:uint):String

執行階段版本: AIR 1.0

從位元組串流或位元組陣列讀取 UTF-8 位元組的序列,並傳回字串。

參數

length:uint — 要讀取的位元組數。

傳回值
String — 指定之長度字元的位元組表示法所產生的 UTF-8 字串。

事件
ioError:IOErrorEvent — 檔案無法讀取或檔案未開啟。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用讀取功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法讀取 (例如,因為檔案遺失)。
 
EOFError — 為讀取資料指定的位置超過可用的位元組數 (由 bytesAvailable 屬性指定)。

    truncate

()方法 
public function truncate():void

執行階段版本: AIR 1.0

在 FileStream 物件之 position 屬性所指定的位置上截斷檔案。

position 屬性所指定的位置到檔案結尾的位元組會被刪除。檔案必須開啟供寫入。


擲回值
IllegalOperationError — 檔案未開啟供寫入。

相關 API 元素


範例  ( 如何使用本範例 )

下列程式碼會以同步方式開啟使用者文件目錄 Apollo Test 子目錄中的 test.txt 檔案,而且如果檔案的長度超過 100 個字元,則會將檔案的長度修剪為 100 個字元。
import flash.filesystem.*;

var file:File = File.documentsDirectory;
file = file.resolvePath("Apollo Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(file, FileMode.UPDATE);
if (file.size > 100) {
    fileStream.position = 100;
    fileStream.truncate();
}
fileStream.close();

下列程式碼會以「非同步」方式開啟使用者文件目錄 Apollo Test 子目錄中的 test.txt 檔案,而且如果檔案的長度超過 100 個字元,則會將檔案的長度修剪為 100 個字元。
var file:File = File.documentsDirectory;
file = file.resolvePath("Apollo Test/test.txt");
var fileStream:FileStream = new FileStream();
fileStream.openAsync(file, FileMode.UPDATE);
trace("start", file.size)
if (file.size > 100) {
    fileStream.position = 100;
    fileStream.truncate();
}
fileStream.addEventListener(Event.CLOSE, fileClosed);
fileStream.close();
function fileClosed(event:Event):void {
    trace("closed", file.size); 
}

    writeBoolean

()方法 
public function writeBoolean(value:Boolean):void

執行階段版本: AIR 1.0

會寫入 Boolean 值。 會根據 value 參數寫入單一位元組;如果為 true 則為 1,如果為 false 則為 0。

參數

value:Boolean — Boolean 值,用以決定寫入的位元組。如果參數為 true 則會寫入 1,如果為 false 則會寫入 0。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeByte

()方法 
public function writeByte(value:int):void

執行階段版本: AIR 1.0

會寫入位元組。 使用參數的較低 8 位元,而忽略其餘較高 24 位元。

參數

value:int — 整數的位元組值。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeBytes

()方法 
public function writeBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void

執行階段版本: AIR 1.0

length 指定的長度,從指定的位元組陣列 bytes,將位元組序列從 offset 所指定的位元組 (使用從零開始的索引) 開始寫入檔案串流、位元組串流或位元組陣列。

如果省略 length 參數,便會使用 0 的預設長度,並從 offset 位置開始寫入整個緩衝區。如果也省略 offset 參數,便會寫入整個緩衝區。

如果 offsetlength 參數超出範圍,這兩者便會固定至 bytes 陣列的開頭與結尾。

參數

bytes:ByteArray — 要寫入的位元組陣列。
 
offset:uint (default = 0) — 從零開始的索引,指定要在陣列中開始寫入的位置。
 
length:uint (default = 0) — 無正負號的整數,指定要在緩衝區中寫入的長度。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeDouble

()方法 
public function writeDouble(value:Number):void

執行階段版本: AIR 1.0

會寫入 IEEE 754 雙精度 (64 位元) 浮點數。

參數

value:Number — 雙精度 (64 位元) 浮點數。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeFloat

()方法 
public function writeFloat(value:Number):void

執行階段版本: AIR 1.0

會寫入 IEEE 754 單精度 (32 位元) 浮點數。

參數

value:Number — 單精度 (32 位元) 浮點數。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeInt

()方法 
public function writeInt(value:int):void

執行階段版本: AIR 1.0

會寫入 32 位元的具有正負號整數。

參數

value:int — 做為具有正負號整數的位元組值。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeMultiByte

()方法 
public function writeMultiByte(value:String, charSet:String):void

執行階段版本: AIR 1.0

使用指定的字元集,將多位元組字串寫入檔案串流、位元組串流或位元組陣列。

參數

value:String — 要寫入的字串值。
 
charSet:String — 表示要使用之字元集的字串。 可能的字元集字串包括 "shift-jis""cn-gb""iso-8859-1",以及其他等等。 如需完整清單,請參閱「支援的字元集」


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

相關 API 元素

    writeObject

()方法 
public function writeObject(object:*):void

執行階段版本: AIR 1.0

使用 AMF 序列化格式,將物件寫入檔案串流、位元組串流或位元組陣列。

參數

object:* — 要序列化的物件。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

相關 API 元素

    writeShort

()方法 
public function writeShort(value:int):void

執行階段版本: AIR 1.0

會寫入 16 位元整數。 使用參數的較低 16 位元,而忽略其餘較高 16 位元。

參數

value:int — 整數的位元組值。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeUnsignedInt

()方法 
public function writeUnsignedInt(value:uint):void

執行階段版本: AIR 1.0

會寫入 32 位元的無正負號整數。

參數

value:uint — 做為無正負號整數的位元組值。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeUTF

()方法 
public function writeUTF(value:String):void

執行階段版本: AIR 1.0

將 UTF-8 字串寫入檔案串流、位元組串流或位元組陣列。會先寫入 UTF-8 字串的長度 (以位元組為單位,16 位元整數),後面緊接著表示字串之字元的位元組。

參數

value:String — 要寫入的字串值。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
RangeError — 如果字串的長度大於 65535 個字元。
 
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。

    writeUTFBytes

()方法 
public function writeUTFBytes(value:String):void

執行階段版本: AIR 1.0

會寫入 UTF-8 字串。 類似 writeUTF(),但是不以 16 位元長度的字做為字串前置詞。

參數

value:String — 要寫入的字串值。


事件
ioError:IOErrorEvent — 您無法寫入檔案 (例如,因為檔案遺失)。此事件只會針對開啟來進行非同步作業的檔案 (使用 openAsync() 方法) 傳送。

擲回值
IOError — 檔案尚未開啟;檔案已開啟,但未使用寫入功能來開啟;或者針對同步作業開啟的檔案 (使用 open() 方法),檔案無法寫入 (例如,因為檔案遺失)。
事件詳細資訊
    

close

事件
事件物件類型: flash.events.Event
屬性 Event.type = flash.events.Event.CLOSE

執行階段版本: AIR 1.0

表示已藉由明確呼叫 close() 方法關閉串流。

Event.CLOSE 常數會定義 close 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target其連線已關閉的物件。

相關 API 元素

    

complete

事件  
事件物件類型: flash.events.Event
屬性 Event.type = flash.events.Event.COMPLETE

執行階段版本: AIR 1.0

指出已到達串流結尾。

Event.COMPLETE 常數會定義 complete 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target已完成載入的網路物件。

相關 API 元素

    

ioError

事件  
事件物件類型: flash.events.IOErrorEvent
屬性 IOErrorEvent.type = flash.events.IOErrorEvent.IO_ERROR

執行階段版本: AIR 1.0

表示非同步檔案 I/O 作業期間發生錯誤。

定義 ioError 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
errorID與特定錯誤相關聯的參考號碼 (僅限 AIR)。
target遭遇輸入/輸出錯誤的網路物件。
text要顯示為錯誤訊息的文字。
    

outputProgress

事件  
事件物件類型: flash.events.OutputProgressEvent
屬性 OutputProgressEvent.type = flash.events.OutputProgressEvent.OUTPUT_PROGRESS

執行階段版本: AIR 1.0

指出緩衝資料已寫入檔案。

定義 outputProgress 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
bytesPending在偵聽程式處理事件時,要寫入的剩餘位元組數。
bytesTotal如果寫入程序成功,最後將會寫入的位元組總數。
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target回報進度的 FileStream 物件。
    

progress

事件  
事件物件類型: flash.events.ProgressEvent
屬性 ProgressEvent.type = flash.events.ProgressEvent.PROGRESS

執行階段版本: AIR 1.0

指出串流上新資料的可用性。

定義 progress 事件物件的 type 屬性值。

這個事件具有下列屬性:

屬性
bubblesfalse
bytesLoaded在偵聽程式處理事件時,載入的項目或位元組數目。
bytesTotal如果載入程序成功時,最終將載入的項目或位元組總數。
cancelablefalse;沒有要取消的預設行為指令。
currentTarget正主動使用事件偵聽程式處理 Event 物件的物件。
target回報進度的物件。




[ X ]為什麼顯示英文?
「ActionScript 3.0 參考」的內容是以英文顯示

並非所有「ActionScript 3.0 參考」的內容都翻譯為所有語言。當語言元素未翻譯時,就會以英文顯示。例如,ga.controls.HelpBox 類別並沒有翻譯為任何語言。因此在參考的繁體中文版本中,ga.controls.HelpBox 類別就會以英文顯示。