file-io

Reading a file and storing names and numbers in two arrays

故事扮演 提交于 2019-12-31 07:01:12
问题 I'm working on a program that reads a file and stores the names and scores in two separate arrays, but I'm struggling. This is what I have so far. I created an array for names called names, but I'm confused how I would copy the names into each index of the array. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ScannerReadFileSplit { public static void main(String[] args) { File file = new File("NamesScore.txt"); String[] names = new String[100

Using fgets to copy lines into string array?

喜你入骨 提交于 2019-12-31 07:01:08
问题 I've got a C program that I'm trying to write which intends to reverse the lines of a file. I am still very inept at C (though I come from a Java background), so I am very likely making mistakes with pointers and such, but I've tried consulting the manual at every turn. This is somewhat of an assignment. The point of the program is to reverse a file's contents, up to MAX_LINES in number, each line being no longer than MAX_CHARS. The method I wanted to try is the following: use fgets to read

Reading a file and storing names and numbers in two arrays

落爺英雄遲暮 提交于 2019-12-31 07:00:28
问题 I'm working on a program that reads a file and stores the names and scores in two separate arrays, but I'm struggling. This is what I have so far. I created an array for names called names, but I'm confused how I would copy the names into each index of the array. import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class ScannerReadFileSplit { public static void main(String[] args) { File file = new File("NamesScore.txt"); String[] names = new String[100

Using C, to print out an array from textFile

醉酒当歌 提交于 2019-12-31 05:48:04
问题 I'm trying to create a code, which reads from textile, and then stores the data into memory, prints out to the screen so the user can read it, but it is still saved into the memory so you can use it for the rest of the program.. Here is the sample of the textile 75 nevermind nvm not much nm no problem np people ppl talk to you later ttyl because cuz i don't know idk as soon as possible asap yeah ya how are you hru you the list goes on, it has a total of 150 words, 151 lines if the first

Move Raw file to SD card in Android

一曲冷凌霜 提交于 2019-12-31 05:42:27
问题 I have a method that will copy an Audio file from raw folder to SD card . It takes two inputs ressound: .ogg Audio Raw file id. fName: the file name of the raw file in the SD card. Updated public boolean saveas(int ressound, String fName){ byte[] buffer=null; InputStream fIn = getBaseContext().getResources().openRawResource(ressound); int size=0; try { size = fIn.available(); buffer = new byte[size]; fIn.read(buffer); fIn.close(); } catch (IOException e) { // TODO Auto-generated catch block

Use a Remote XML as File [duplicate]

◇◆丶佛笑我妖孽 提交于 2019-12-31 05:18:07
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to read XML response from a URL in java? I'm trying to read an XML file from my web server and display the contents of it on a ListView , so I'm reading the file like this: File xml = new File("http://example.com/feed.xml"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(xml); doc

Reading .txt file from another directory

独自空忆成欢 提交于 2019-12-31 05:01:27
问题 The code I am running is in /Test1/Example . If I need to read a .txt file in /Test1 how do I get Java to go back 1 level in the directory tree, and then read my .txt file I have searched/googled and have not been able to find a way to read files in a different location. I am running a java script in an .htm file located at /Test1/Test2/testing.htm. Where it says script src=" " . What would I put in the quotations to have it read from my file located at /Test1/example.txt . 回答1: In Java you

saving file after passing parameter

邮差的信 提交于 2019-12-31 04:02:09
问题 Here is the parent question: save string to file I want to pass the parameter which will be saved in file(.csv) after clicking button. @bigtable is a table with strings in each row. Here is the code in my show.html.erb: ...some code here... <%= form_tag do %> <% text_field_tag, id = "bigtable", value = @bigtable.to_s %> <%= submit_tag 'Zapisz' %> <% end %> and my controller method: def savefile @bigtable = param[:bigtable] @bigtable.join("\n") File.open("path/to/file", "w") { |file| file

load command in matlab loading blank file

牧云@^-^@ 提交于 2019-12-31 03:30:10
问题 I am loading a file in matlab, but it is being loaded as an empty variable. positive 0x0 [] and am using load positive.txt but the file is not empty. Is the something am wrong? P.S. I have loaded other files from the same folder successfully. Also I tried to rename it to positive.dat but that also didn't work. And it was an excel file that I saved as an text file. and the first couple entries of the file, copied & pasted 04 10 19 04 10 36 04 10 28 04 16 16 04 14 01 04 20 21 04 20 06 04 20 28

how to faster read text file to ArrayList on android

你离开我真会死。 提交于 2019-12-31 02:09:08
问题 I have a problem with fast read txt file to ArrayList. If I want read a file size 0,9MB, I must wait 5min. If files size is 34MB (partialy, because android does not accept larger than 1MB files), it's completely not working. I think that process should be max few second. This is a code: String word; public ArrayList<String> dictionary = new ArrayList<String>(); public void setup() { try { AssetManager assetManager = getAssets(); InputStream inputf; inputf = assetManager.open("dict_1.txt");