w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to read a resource file in Java standalone applications
An embedded resource is not a File, it is a resource. You can read these resources using Class#getResource or Class#getResourceAsInputStream depending on your needs. For example... URL url = getClass().getResource("/templates/some.xml"); Will return a URL reference to the named resource.

Categories : Java

UniObjects for Java read object code file
This is what we ended up doing: I couldn't find a way to make the dataset read the binary code, so I read the items one at a time using a subroutine. Before the items could be read I had to install and run a UniBasic subroutine on the database to encode the item into base 64 using something like this: ... LOOP READBLK A.BYTE FROM FILE, 1 THEN NULL ELSE DONE = TRUE UNTIL DONE DO TO.ENCODE = TO.ENCODE : A.BYTE REPEAT ENCODE('Base64', 1, TO.ENCODE, 1, RET.VALUE, 1) ... This subroutine returned the base 64 encoded item as a Stringto UOJ and then it could be decoded and no data was lost. Here is an example of the Java Code: ... UniSubroutine readBlkSub = unisession.subroutine(routineName, 4); readBlkSub.setArg(0, getNameID()); readBlkSub.setArg(1, itemName); readBlkSub.call(); fi

Categories : Java

Standalone java code to invoke wso2 secured web service
You could try taking a look at the Rampart samples. Basic Sample 01 is UsernameToken Authentication. The source code is here: link

Categories : Security

Getting NULL after create external table in Hive using parquet file as storage
In my case, HDFS file was in comma delimited format, I was not defining row format delimited in command. Like: CREATE EXTERNAL TABLE TABLENAME(COL1 INT, COL2 STRING....) LOCATION '/user/....'; it used to create table with same number of rows but with all values as null. I modified above command as follows and it works as charm: CREATE EXTERNAL TABLE TABLENAME (COL1 INT, COL2 STRING....) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY ' ' LOCATION '/user/.....';

Categories : Hadoop

How to create a standalone SQL DB file to use with my java chat application?
I am not sure if I understand your question properly, but reading about Minecraft plugins and SQL file somehow tells me that you actually miss some basic knowledge about the databases and server communication and that is what the question is really about. So to clarify. Databases: If you have a file which contains a database it is the SQLite Database. Here is the homepage of the project: LINK. You can do further googling about the project to fully understand it. However mySql is a separate database type, not based on sql files itself. In both databases (and others too) communication with the database, when using java or other programming language does not imply sql files to be created and managed, but is usually done through ORM link mechanism such as Hibernate homepage (for Java). T

Categories : Java

Java Standalone runnable GUI application - can't get jar file to open the program
Again: "you can use Java resources to load the properties file as an embedded-resource (see the tag info for related tutorials), though you can't store values there that are going to change". You haven't said whether they're going to change. If you are going to store a few things, the (new-ish) way to do that is with the java.util.Preferences API. If you really need your own file, I suppose the user's' home directory is the place to put a directory of your own in which to store the file, look up user.home as a system parameter.

Categories : Java

Need help trying to read Sharepoint folder from a standalone windows application (c# based)
Use the Managed Client Object Model: http://msdn.microsoft.com/en-us/library/ee857094(v=office.14).aspx ...or connect to the folder via SharePoint's web services: http://sarangasl.blogspot.com/2009/12/sharepoint-list-web-service.html

Categories : C#

Python 3 code to read CSV file, manipulate then create new file....works, but looking for improvements
You can greatly simplify your code using more of numpy capabilities. A = np.loadtxt('stack.txt',skiprows=2,delimiter=',',dtype=str) keep_headers=np.loadtxt('keepheader.csv',delimiter=',',dtype=str) headers = A[0,:] cols_to_keep = np.in1d( headers, keep_headers ) B = np.float_(A[1:,cols_to_keep]) np.savetxt('cmap.csv',B,fmt='%.3f',delimiter=",")

Categories : Csv

Trying to read from a text file in java getting error: Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
You might want to change your = which assigns true to f by a comparaison operator == if (f == true) { this.setVisible(false); w.setVisible(true); } else { System.out.println("It works"); }

Categories : Misc

How to read from a file using C# code?
The issue is while (!reader.EndOfStream) because when you initially read it in the position is at the end of the file. This is solidified by the fact that the line arr[i] should fail because you've not initialized the array (in fact, it shouldn't even compile...). So, how about this: double[] arr = new double[2]; ... reader.BaseStream.Position = 0; while (!reader.EndOfStream) { arr[i] = Convert.ToDouble(reader.ReadLine()); i++; } However, a more straight forward approach would be something like this: var arr = new List<double>(); var lines = File.ReadAllLines(Application.StartupPath+"\City.txt"); foreach (var l in lines) { arr.Add(Convert.ToDouble(l)); } return arr.ToArray();

Categories : C#

How to read Java byte code with Eclipse only in the console?
In your project directory, navigate to /bin , and there you will most likely have the .class-files that were automatically generated by Eclipse. To see the java code for a compiled class file, you will have to use a java decompiler, such as this one. The .class-file itself is compiled binary Java code, Eclipse automatically views the source for the class if any source for the class has been linked in your build path.

Categories : Java

How to read executables stdout stderr from Java code?
Runtime tr = Runtime.getRuntime(); try { Process p = tr.exec("c:\a.bat"); InputStream err = p.getErrorStream(); InputStream std = p.getInputStream(); //TODO here we go! } catch (IOException e) { e.printStackTrace(); }

Categories : Java

How to turn off code generation in Simulink? (function is not supported for standalone code generation)
You need to uncomment the coder.extrinsic('imresize'); line and declare/initialise the InImage variable before calling the imresize function. See Converting mxArrays to Known Types for more info. EDIT following discussion in the comments: The following should work: function OutImage = ResizeCropPad(InImage, Width, Height) %#codegen coder.extrinsic('imresize'); % resizing to defined height scale = Height/size(InImage,1); OutImage = InImage; OutImage = imresize(InImage, scale); % cropping to defined width if Width<size(OutImage,2) padarray(OutImage, [0 size(OutImage,2)-Width], 0, 'both'); elseif Width>size(OutImage,2) b = floor((Width-size(outImage,2))/2); OutImage = OutImage(:,b:b+Width-1,:); end

Categories : Matlab

Cant read file within source code
The problem here is that when you run your program in Eclipse, the code is run from the directory containing the code, whereas Jenkins runs it from some other directory. Thus, ./ does not refer to the directory containing the code. You can use the getResourceAsStream method to load resources from locations in your classpath, and apparently deals with JAR bundling too. This article on resource loading should explain things somewhat. However, this method should only really be used for files that the user never needs to interact with. If you want to store a user-edited configuration file, for example, it should be put somewhere else, such as an Application Data directory.

Categories : Java

How to read data from a file and put it into variable and output to a different file. Java
Try using BufferedReader BufferedReader pw = new BufferedReader(new FileReader(fileName)); String s = null; s = pw.readLine(); Working example public static void main(String[] args) throws IOException { Scanner keyboard = new Scanner(System.in); String filePath = keyboard.next(); BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath)); String line = bufferedReader.readLine(); System.out.println(line); } Enter path on console as C:UserspathDesktop1.txt You can use PrintWriter to write PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName2)));

Categories : Java

Read .doc file content and write into pdf file in java
Regarding your exception: Your code iterates over all paragraphs and calls isInTable() for each one of them. Since tables are commonly composed of several such paragraphs, your call to getTable() also gets executed several times for a single table. However, what your code should do instead is to find the first paragraph of a table, then process all paragraphs therein (via getRow(m).getCell(n)) and ultimately continue with the outer loop in the first paragraph after the table. Codewise this may look roughly like the following (assuming no merged cells, no nested tables and no other funny edge cases): if (par.isInTable()) { Table table = range.getTable(par); for (int rn=0; rn<table.numRows(); rn++) { TableRow row = table.getRow(rn); for (int cn=0; cn<row.numC

Categories : Java

Batch code to read text file
The issue is that the wmic is outputing UTF-16 format which is indicated by the FF FE at the start of the file (Hex Dump Tool). The command FOR can not understand the Unicode format and is not finding anything. You will need an intermediate step to convert the abc.txt into plain text. This explains why when you manually create in plain text format the file it works as expected. Add the following to your second batch file which will do the conversion. TYPE abc.txt > abcplain.txt FOR /F "skip=1" %%m IN (abcplain.txt) DO (echo %%m)

Categories : Batch File

I want Java code to convert word file (doc file having text, images, tables etc. ) into pdf file.
You need to add the latest jar in the java build path. Check your projects build path and make sure the jar is present there. Do a clean build and clean publish and it should work. If not then you can even try to directly paste the jar in your projects deployment location (LIB folder).

Categories : Java

Compiling a standalone C# file at runtime which references another file
Typically a compiler will only compile source files that it's been told to compile in a single pass. ie: specify all .cs names on the command line, or specify to compile all .cs files in a given folder. In this case: string []arrCode = { code, "base.cs" }; CompilerResults results = compiler.CompileAssemblyFromSource(compilerparams, arrCode); Alternative syntax: CompilerResults results = compiler.CompileAssemblyFromSource(compilerparams, code, "base.cs");

Categories : C#

Can I put C# and Java code in the same file to make porting my code easier?
I would say the idea is good, but the code would be hard to read. A mess. Maybe if you have a very simple codebase... but in reality would result BIG CHAOS! You maybe spend a lot of time by looking at wrong code, scrolling up n down and getting more confused. Clean code in the files will have your focus, when you open your java project you know you work with java. And when you do open the c# you know it is C# etc. Do a java branch and a c# branch of your code. It is more easy to maintain and keep it clean. Think of situation where you want to upgrade the environment, why wasting time/money to recompile the Java code while you are about to upgrade only the C# code, etc! Will you port to php, ruby, perl, python etc in same files too ? Just let programmers to open the code they want to

Categories : C#

Using Facebook Graph API, how can I print a user's full name in a standalone ruby code?
Impossible with That Data want an authentication for access it. such as email, likes, bio and so on But If you access 'public user's profile' You can connect "http://graph.facebook.com/username" to access it.

Categories : Ruby

How to import source code or project by the eclipse plugin of Dynamsoft SAW standalone?
This is Rachel from Dynamsoft. I'm afraid currently SourceAnywhere Eclipse plugin doesn't support importing project from source control server directly. I will forward your request to our R&D team for future consideration. Currently, you can perform Get from SourceAnywhere GUI client (Windows/Java/Mac) and then open the project in Eclipse. Thank you for using SourceAnywhere.

Categories : Eclipse

Read srt file in java
Note that these programs already exists. Search for: BufferedReader, InputStreamReader, FileInputStream. Use them like this: BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); String line; while ((line = reader.readLine()) != null) { System.out.println(line); }

Categories : Java

How can i code a function that can read a text file and write into a list?
This is a two-liner in Python with open("myfile.txt") as file: lines = file.readlines() lines is then a list of the lines of the file. Each will end with a ' ' (newline) character, except possibly the last line.

Categories : Python

How to read from a file I already wrote in it using Java
I think you need to close your BufferedWriter. Then you can read the file and you will get your written content. An example of the writer is here

Categories : Java

How to read from a JSON file in Java
In this line you are only reading in one line to create the JSON object. JSONObject json = new JSONObject(line); It should use the StringBuilder which contains the entire JSON String. JSONObject json = new JSONObject(sb.toString());

Categories : Java

Read one line of a csv file in Java
You can do something like this: BufferedReader reader = new BufferedReader(new FileReader(<<your file>>)); List<String> lines = new ArrayList<>(); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } System.out.println(lines.get(0)); With BufferedReader you are able to read lines directly. This example reads the file line by line and stores the lines in an array list. You can access the lines after that by using lines.get(lineNumber).

Categories : Java

Java: read bytes from a utf-8 file
But the Unicode character for degrees actually is two bytes when encoded as UTF-8. A degree symbol is represented by the bytes c2 b0. You can use RandomAccessFile in Java if you really want to read bytes at specific offsets in a file, but I doubt that's what you really want. Probably the easiest way to do what it seems you want is to use a FileReader and either read into an array of char of size 9, or read just 9 characters into a larger char array. For example: try (Reader reader = new InputStreamReader(new FileInputStream(filename), "UTF-8")) { char[] buffer = new char[1024]; reader.read(buffer, 0, 9); }

Categories : Java

Java: read a file when it is updated
You can use Java 7's WatchService to accomplish this for you. Here's the official tutorial.

Categories : Java

How to read until end of file (EOF) using BufferedReader in Java?
You are consuming a line at, which is discarded while((str=input.readLine())!=null && str.length()!=0) and reading a bigint at BigInteger n = new BigInteger(input.readLine()); so try getting the bigint from string which is read as BigInteger n = new BigInteger(str); Constructor used: BigInteger(String val) Aslo change while((str=input.readLine())!=null && str.length()!=0) to while((str=input.readLine())!=null) see related post string to bigint readLine() Returns: A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached see javadocs

Categories : Java

How to read doc and docx file in java with POI api
Re your first issue, I guess you need to reference the depencencies in your project. Namely I guess: poi-ooxml-schemas xmlbeans, which is in poi-ooxml-schemas-version-yyyymmdd.jar (from the Apache POI page). Here is the Apache XMLBeans page. I'm not able to list every library you require, but you can probably figure out through maven...

Categories : Java

How can I pass data read from a JSON file to the rest of my Javascript code?
$.getJSON runs asynchronously. The function that you pass to it is a "callback", which means that it gets called when getJSON comes back from doing its thing. If you want to do something with the JSON data that you get back, you must wait for the callback to execute. Also, on a side note, $.parseJSON(JSON.stringify(data)) is redundant. The data object is already a perfectly usable object with your data in it, but you're turning that object back into a JSON string and then immediately back into an object. Just use data as is. For more information, check out the jQuery API docs for getJSON.

Categories : Javascript

Best way to automate the verification of hundreds of standalone Java programs?
I think I might do it via subversion. Separate directory per assignment. Students check in when they're ready, which triggers a JUnit test to be run. I'm not sure you can get away without writing code yourself. The unit test would have to figure out whose code it's running, and then run it etc. Not sure if doing it in the unit test, or have jenkins do it would be better though.

Categories : Java

I like to load my EMFText model in a standalone java applicatio
Try this: new MydslMetaInformation().registerResourceFactory(); ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = resourceSet.getResource(URI.createFileURI("example.mydsl"), true); Model model = (Model) resource.getContents().get(0);

Categories : Misc

Simplest way to read from a JSON file in Java?
Take a look here for an example of how to use gson to convert it to nice juicy data: Converting JSON to Java

Categories : Java

Trying to read the full XML file as a String in Java
There is syntax error in your xml. The attributes of the element should not be separated by a comma. It should be like, <?xml version="1.0" encoding="UTF-8"?> <app hash='nv' name='Tech' package='1.0' version='13' filesize='200' create_date='01-03-1987' upate_date='07-09-2013' > <url> <name>RJ</name> <score>10</score> </url> <url> <name>ABC</name> <score>20</score> </url> </app>

Categories : Java

how to edit a file in java that becomes read-only at run-time
Your build should not have a runtime dependence on a file in your source tree. You instead should copy the necessary file from your source tree into your build tree as part of the build process (where it then can freely change the permissions to be writable). Your build then should depend on that copy of the file.

Categories : Java

How to read portions of text from a .txt file in Java?
The Scanner class has a set of hasNextXyz() and nextXyz() methods that can be used to pick and convert values separated by some delimiter. String lineOfInts = "1,5,10,15,20"; Scanner scanner = new Scanner(lineOfInts).useDelimiter(","); while (scanner.hasNextInt()) { System.out.println(scanner.nextInt()); } See Scanner#nextInt() for more info.

Categories : Java

can not read file from linux system using java
Are you running your program as root? it is not sufficient changing the permissions of /root/temp, if you are not the user root you wont be able to "go through" the dir /root unless you also change the permissions of the dir /root .

Categories : Java

Read regex from properties file in java
Just read using a classical BufferedReader instead: final URL url = MyClass.class.getResource("/path/to/propertyfile"); // check if URL is null; String line; try ( final InputStream in = url.openStream(); final InputStreamReader r = new InputStreamReader(in, StandardCharsets.UTF_8); final BufferedReader reader = new BufferedReader(r); ) { while ((line = reader.readLine()) != null) // process line } Adapt to Java 6 if necessary...

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.