read

Unzipping zip file gives “java.util.zip.ZipException: Cannot read version” or “java.util.ZipException Cannot read local header version 45”

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like just to extract a normal zip file, but it keeps failing. This is my code I'm using now: private File downloadPath = new File(Environment.getExternalStorageDirectory() + "/Test/file.zip"); private File unzipLoc = new File(Environment.getExternalStorageDirectory() + "/Test/"); FileInputStream fin = new FileInputStream(downloadPath); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null; while ((ze = zin.getNextEntry()) != null) { FileOutputStream fout = new FileOutputStream(unzipLoc + ze.getName()); for (int c = zin

How to read custom config section in app.config in c#

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to read following custom section from app.config: <StartupFolders> <Folders name="a"> <add folderType="Inst" path="c:\foo" /> <add folderType="Prof" path="C:\foo1" /> </Folders> <Folders name="b"> <add folderType="Inst" path="c:\foo" /> <add folderType="Prof" path="C:\foo1" /> </Folders> </StartupFolders> I found this link , but it does not say for multiple <Folders> tag. Please help? 回答1: Hi You can Access custom sections like this CustomConfigClass section = (CustomConfigClass)ConfigurationManager.GetSection("StartupFolders"); Hope

Is boost shared_ptr &lt;XXX&gt; thread safe?

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a question about boost::shared_ptr . There are lots of thread. using namespace boost; class CResource { // xxxxxx } class CResourceBase { public: void SetResource(shared_ptr res) { m_Res = res; } shared_ptr GetResource() { return m_Res; } private: shared_ptr m_Res; } CResourceBase base; //---------------------------------------------- // Thread_A: while (true) { //... shared_ptr nowResource = base.GetResource(); nowResource.doSomeThing(); //... } // Thread_B: shared_ptr nowResource; base.SetResource(nowResource); //... Q1 If Thread_A

read.delim() - errors “more columns than column names” and “header and &#039;&#039;col.names” are of different lengths\&quot;

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Preliminary information OS: Windows XP Professional Version 2002 Service Pack 3; R version: R 2.12.2 (2011-02-25) I am attempting to read a 30,000 row by 80 column, tab-delimited text file into R using the read.delim() function. This file does have column headers with following naming convention: "_". The code that I use to attempt to read the data in is: cc <- c("integer", "character", "integer", rep("character", 3), rep("integer", 73)) example_data <- read.delim(file = 'C:/example.txt', row.names = FALSE, col.names = TRUE, as.is = TRUE,

How to read txt file and replace word in R?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In file a.txt containing "abc", I want to replace "abc" with "ccccccccccccccccccccc", How to read and replace in R? Thank you! a.txt contents: {\rtf1 {\fonttbl{\f1\fmodern\fcharset134;}} {\info} \sectd\pgwsxn11907\pghsxn16840\marglsxn1418\margrsxn1418 \margtsxn1440\margbsxn1440\sectdefaultcl \headery851{\header\pard\qr\fs18\par} \footery992{\footer\pard\qc\f0\fs18\chpgn\par} \pard\qc\sb30\sa30\fs21 \par \trowd\trautofit1\trgaph0\trleft-75\intbl\trqc \clbrdrt\brdrs\brdrw30\clbrdrb\brdrs\brdrw10\clvertalc\cellx6993\clbrdrt \brdrs\brdrw30

Display a audio waveform using C#

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've already searched at Stackoverflow and google, but haven't found what I'm looking for. So far I got the audio raw data(WAV File) and I want to visualize it. private void Form1_Load(object sender, EventArgs e) { FileStream fs = new FileStream("D:\\tada.wav", FileMode.Open); BinaryReader reader = new BinaryReader(fs); char[] data = new char[4]; long fsize; long wfxSize; long dataSize; WaveFormatEx wfx; //RIFF reader.Read(data, 0, 4); fsize = reader.ReadInt32(); //WAVE reader.Read(data, 0, 4); //FMT reader.Read(data, 0, 4); wfxSize = reader

How to Import a CSV file containing multiple sections into R?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to import the contents of a csv file into R, the csv file contains multiple sections of data vertically, seperated by blank lines and asterisks. For example ******************************************************** * SAMPLE DATA ****************************************** ******************************************************** Name, DOB, Sex Rod, 1/1/1970, M Jane, 5/7/1980, F Freddy, 9.12,1965, M ******************************************************* * Income Data **************************************** ******************************

seek(), then read(), then write() in python

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When running the following python code: >>> f = open(r"myfile.txt", "a+") >>> f.seek(-1,2) >>> f.read() 'a' >>> f.write('\n') I get the following (helpful) exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> IOError: [Errno 0] Error The same thing happens when openning with "r+". Is this supposed to fail? Why? Edit: Obviously, this is just an example, not what I am actually trying to execute. My actual goal was to verify that the files ends with "\n", or add one, before adding the new lines. I am working under

C++ Read file line by line then split each line using the delimiter

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to read a txt file line by line and after reading each line, I want to split the line according to the tab "\t" and add each part to an element in a struct. my struct is 1*char and 2*int struct myStruct { char chr ; int v1 ; int v2 ; } where chr can contain more than one character. A line should be something like: randomstring TAB number TAB number NL 回答1: Try: Note: if chr can contain more than 1 character then use a string to represent it. std :: ifstream file ( "plop" ); std :: string line ; while ( std :: getline ( file

JMeter TCP Sampler incorrectly reports 500

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using JMeter to load test our SMTP server using the TCP Sampler (BinaryTCPClientImpl class) to fire HELOs, wait for 30 seconds and then QUITing. The SMTP server accepts the HELO and responds accordingly, with JMeter logging the correct response, however it does not appear to find then of the response and instead hits the response timeout and shows a 500 fail for the request. In the JMeter logs it says: ERROR - jmeter.protocol.tcp.sampler.TCPSampler: org.apache.jmeter.protocol.tcp.sampler.ReadException: at org.apache.jmeter.protocol.tcp