fileoutputstream

Why does saving a bitmap take so long?

允我心安 提交于 2019-12-18 04:17:09
问题 So I have an app on Google Glass that takes a picture, then converts it to grayscale and overwrites the original image in memory: private void rGBProcessing (final String picturePath, Mat image) { //BitmapFactory Creates Bitmap objects from various sources, //including files, streams, and byte-arrays Bitmap myBitmapPic = BitmapFactory.decodeFile(picturePath); image = new Mat(myBitmapPic.getWidth(), myBitmapPic.getHeight(), CvType.CV_8UC4); Mat imageTwo = new Mat(myBitmapPic.getWidth(),

How to write new line in Java FileOutputStream

北城以北 提交于 2019-12-17 16:56:27
问题 I want to write a new line using a FileOutputStream ; I have tried the following approaches, but none of them are working: encfileout.write('\n'); encfileout.write("\n".getbytes()); encfileout.write(System.getProperty("line.separator").getBytes()); 回答1: It could be a viewer problem... Try opening the file in EditPlus or Notepad++. Windows Notepad may not recognise line feed of another operating system. In which program are you viewing the file now? 回答2: This should work. Probably you forgot

FileOutputStream.close is really slow when writing large file

*爱你&永不变心* 提交于 2019-12-17 14:50:33
问题 I have a method which receives a file over a TCP socket using this code: FileOutputStream fileStream = new FileOutputStream(filename.getName()); while (totalRead < size) { if (size - totalRead > CHUNKSIZE) { read = getInputStream().read(buffer, 0, CHUNKSIZE); } else { read = getInputStream().read(buffer, 0, size - totalRead); } totalRead += read; fileStream.write(buffer, 0, read); fileStream.flush(); if (System.currentTimeMillis() > nextPrint) { nextPrint += 1000; int speed = (int) (totalRead

Get file name from FileOutputStream

橙三吉。 提交于 2019-12-17 06:49:17
问题 Is there a way to get the file name from a FileOutputStream or from FileInputStream ? 回答1: Looks like the answer is no: http://download.oracle.com/javase/1.4.2/docs/api/java/io/FileOutputStream.html http://docs.oracle.com/javase/7/docs/api/index.html?java/io/FileOutputStream.html There are no public methods that return the File or String used in construction of the stream. EDIT: The same holds for FileInputStream . 回答2: This feature is not provided by the out-of-the-box File-Input/Output

How to write data with FileOutputStream without losing old data?

强颜欢笑 提交于 2019-12-17 02:13:05
问题 If you work with FileOutputStream methods, each time you write your file through this methods you've been lost your old data. Is it possible to write file without losing your old data via FileOutputStream ? 回答1: Use the constructor that takes a File and a boolean FileOutputStream(File file, boolean append) and set the boolean to true . That way, the data you write will be appended to the end of the file, rather than overwriting what was already there. 回答2: Use the constructor for appending

Adding a node to same xml file on sd card under its root tag in android

隐身守侯 提交于 2019-12-13 18:22:12
问题 Hello friends I have this code in which I am writing an xml file to my sd card: public class SingleItemView extends Activity { File newxmlfile = new File(Environment.getExternalStorageDirectory() + "/testfinal.xml"); TextView txtmdname,txtutcost,txtdesc,txtmodno; // Declare Variables String mdname; String utcost; String desc; String modno; String flag; String toolscat; String tan; int number; String numberOfItems; ProgressDialog mProgressDialog; Bitmap bmImg = null; ImageView addToCartButton;

how can i Merge files

寵の児 提交于 2019-12-13 11:03:21
问题 How can i wright in the beggining of the first file infomation which contains in second file, so that they merge each other?? please help, thanks. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); FileInputStream fileReader = new FileInputStream(reader.readLine()); FileOutputStream fileWriter = new FileOutputStream(reader.readLine(), true); while (fileReader.available() > 0) { int data = fileReader.read(); fileWriter.write(data); } fileReader.close(); fileWriter

FileOutputStream write non-existent bytes

一曲冷凌霜 提交于 2019-12-12 06:42:36
问题 I have a problem with FileOutputStream. I use this simple code: byte[] data1 = BD25Writer.getData1(); byte[] data2 = BD25Writer.getData2(); FileOutputStream dbf = new FileOutputStream(new File(file.getPath(), "file1.dbf")); dbf.write(data1); dbf.close(); FileOutputStream dbt = new FileOutputStream(new File(file.getPath(), "file2.dbt")); dbt.write(data2); dbt.close(); File is written correctly on most platforms (Windows, Android). In HEX-editor it looks like this: But on only one device

Can't save data to file and then load it in Unity3d

不问归期 提交于 2019-12-12 03:26:51
问题 I want to save data of my game to file after starting the game, then after close/start game again I want to load data from that file. I tried to use this solution, but when I start and then stop simulation, I don't see file indicatorsInfo.dat , but Debug.Log() says, that it exists. Anyway it don't load the data, what is wrong? using UnityEngine; using System; using System.Runtime.Serialization.Formatters.Binary; using System.IO; public class GAMEMANAGERFileIO : MonoBehaviour { void OnEnable()

FileOutputStream does not create file

萝らか妹 提交于 2019-12-12 01:44:59
问题 I actually checked other posts that could be related to this and I couldn't find any answer to my question. So, had to create this newly: The file does not get created in the given location with this code: File as = new File ("C:\\Documents and Settings\\<user>\\Desktop\\demo1\\One.xls"); if (!as.exists()) { as.createNewFile(); } FileOutputStream fod = new FileOutputStream(as); BufferedOutputStream dob = new BufferedOutputStream(fod); byte[] asd = {65, 22, 123}; byte a1 = 87; dob.write(asd);