readfile

Is there heredoc alternative in Java (heredoc as PHP)? [duplicate]

一笑奈何 提交于 2019-11-30 17:28:33
This question already has an answer here: Java multiline string 39 answers For JAVA development I need writing to a files with strings like "\r\t\n <>", because from Java I want writing a PHP file. If you can't understand look at this example: BufferedWriter buffW = new BufferedWriter(fileW); buffW.write("<?php\n\n\tclass MyClass {\n\tpublic function test()\n}\n}\n?>"); This is mess a code, I want to write a clean such as PHP can do, but can't find on Java alternative way as example: <?php $mystring = <<<EOT This is some PHP text. It is completely free I can use "double quotes" and 'single

How to let users with required permission download a file via php?

梦想与她 提交于 2019-11-30 15:37:34
问题 I have a php file that acts as a gatekeeper for all the files I want people to download, who ahve sufficient privilages. The code I use throw the file to the user is header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header("Content-disposition: attachment; filename=\"".$public_filename."\""); header("Content-Transfer-Encoding: Binary"); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma:

How to read a file's contents into an SQL variable

旧街凉风 提交于 2019-11-30 14:58:18
问题 Could someone tell me how to read a file's contents into an MS SQL variable using T-SQL? 回答1: DECLARE @FileContents VARCHAR(MAX) SELECT @FileContents=BulkColumn FROM OPENROWSET(BULK'PathToYourFile.sql',SINGLE_BLOB) x; -- BINARY --FROM OPENROWSET(BULK'PathToYourFile.sql',SINGLE_CLOB) x; -- CHAR The SQL Server service account needs to have permissions to read the file obviously. 回答2: Make use of SQLCMD to execute the .sql (either from command prompt or within SSMS). If you want to use it within

Android: how to get list of all preference xml's for my app and read them?

元气小坏坏 提交于 2019-11-30 14:09:57
问题 how to get list of all application preferences for application, 1. I am saving shared preference in this manner 2. I know that they are in data/data/app_packagename/shared_prefs 3. THE PROBLEM: But how to get list of all preference xml files in a spinner and read each preference, i searched in SO, but i did not found any help regarding this, how to do read all preference xml files in my application directory and access the preferences? P.S: I am aware of SharedPreference.getAll(); , will be

Node.js from fs.readFileSync() to fs.readFile()

寵の児 提交于 2019-11-30 11:46:56
问题 I'm trying to get my head around synchronous vs asynchronous in Node.js, in particular for reading an html file. In a request handler, the synchronous version that i'm using, which works is the following: var fs = require("fs"); var filename = "./index.html"; var buf = fs.readFileSync(filename, "utf8"); function start(resp) { resp.writeHead(200, {"Content-type":"text/html"}); resp.write(buf); resp.end(); } exports.start=start; What would be the version using readFile() ?? I understand that

How do I read a file line by line in VB Script?

谁说我不能喝 提交于 2019-11-30 11:11:40
I have the following to read a file line by line: wscript.echo "BEGIN" filePath = WScript.Arguments(0) filePath = "C:\Temp\vblist.txt" Set ObjFso = CreateObject("Scripting.FileSystemObject") Set ObjFile = ObjFso.OpenTextFile(filePath) StrData = ObjFile.ReadLine wscript.echo "END OF FIRST PART" Do Until StrData = EOF(ObjFile.ReadLine) wscript.echo StrData StrData = ObjFile.ReadLine Loop wscript.echo "END" The EOF() function doesn't seem to work: C:\Users\EGr\Documents\Scripts\VB>cscript testloop.vbs ArgVal Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All

No such file or directory while trying to read files in a directory python

谁都会走 提交于 2019-11-30 10:01:33
问题 I have this code which lists the files in the directory and parses each one of them with my function. paths = [] for filename in os.listdir(r"C:\Program Files (x86)\Folder\Folder"): with open(filename) as f: paths.append(parse_file(f)) I am getting the error: File "find.py", line 21, in <module> with open(filename) as f: IOError: [Errno 2] No such file or directory: 'file.txt' This error shows that it saw file.txt because it exist in the folder I specified in os.listdir , I have many more

Open file in ML(SMLNJ)

旧时模样 提交于 2019-11-30 09:54:00
问题 I need to read file in ML (SLMNJ) and save it in some structures. I need to read some data that points to graph declaration: [( 1 , 2 , 13 ),( 2 , 3 , 3 ),( 2 , 4 , 8 ),( 2 , 5 , 4 ),( 3 , 1 , 5 ),( 3 , 4 , 1 ),( 4 , 6 , 5 ),( 5 , 5 , 5 ),( 6 , 4 , 6 )] (first number: name of the node , secend number: name of connected node , third number weight for this mane (each () show one mane ) ) for expamle this is test input how to read file and which structure to save it 回答1: for reading from file

Android: how to get list of all preference xml's for my app and read them?

怎甘沉沦 提交于 2019-11-30 09:36:00
how to get list of all application preferences for application, 1. I am saving shared preference in this manner 2. I know that they are in data/data/app_packagename/shared_prefs 3. THE PROBLEM: But how to get list of all preference xml files in a spinner and read each preference, i searched in SO , but i did not found any help regarding this, how to do read all preference xml files in my application directory and access the preferences? P.S: I am aware of SharedPreference.getAll(); , will be enough to read once i get the file? I have wrote in bits(Rough Code), it give error when tried to run,

Read and split a text file (java)

拟墨画扇 提交于 2019-11-30 09:10:02
问题 I have some text files with time information, like: 46321882696937;46322241663603;358966666 46325844895266;46326074026933;229131667 46417974251902;46418206896898;232644996 46422760835237;46423223321897;462486660 For now, I need the third column of the file, to calculate the average. How can I do this? I need to get every text lines, and then get the last column? 回答1: You can read the file line by line using a BufferedReader or a Scanner , or even some other techinique. Using a Scanner is